App Maker查询多个值并分配给另一个值



我有多个位置有多个问题可以解决。根据位置和问题,票证将被路由到特定的技术人员。我不知道如何查询或过滤多个位置、多个问题、多个技术人员。示例:位置1,计算机问题,发送给计算机技术人员。位置1,布线问题,发送到布线技术人员。

以下是此解决方案(GIF(的结果:将问题分配给技术

首先,你需要设置与模型的关系,这样你就可以通过过滤器进行查询,并根据其类型和位置将问题"分配"给技术人员。您的模型关系如下所示:

一个问题到一个位置
多个问题到一个技术

然后创建问题并将地点和技术与表单小部件关联。如果您想根据标准自动将问题分配给技术,则必须将表单按钮上的默认"创建新项目"onClick功能替换为另一个功能。您可以更改与客户端脚本或服务器脚本的关联。请参阅此处的文档。试试我制作的客户端脚本:

function createAssignIssuePublic(){
// Datasources declaration
var issuesDatasource = app.datasources.Issues;
var locationDatasource = app.datasources.Locations;
// Creates an Issue item(record) and after it's finished a Tech is associated to it.
// Notice the callback function.
issuesDatasource.createItem(function(record){
var techsDatasource = app.datasources.Techs;
// Create a query.
var techsQuery = techsDatasource.query;
var issue = issuesDatasource.item;
var location = issue.Location.Name;
// Setting the conditionals to assign Tech per issue and location
if (issue.Type == "Computer issue"){
// Query by filter (name equals)
techsQuery.filters.Name._equals = "Computer Tech";
// Reloads Tech datasource per previous query filter. 
// Once loaded, it relates the tech item to the issue item/record.
techsDatasource.load(function(){
var relatedTech = techsDatasource.item;
// Changes the Associated Tech
record.Tech = relatedTech;
});
}
// If issue is "Wiring issue" but NOT in a "Critical Location"
else if (issue.Type == "Wiring issue" && location !== "Critical Location"){
techsQuery.filters.Name._equals = "Wiring Tech";
techsDatasource.load(function(){
var relatedTech = techsDatasource.item;                  
record.Tech = relatedTech;
});
}
// If issue is "Wiring issue" but IN in a "Critical Location"
else if (issue.Type == "Wiring issue" && location == "Critical Location"){
techsQuery.filters.Name._equals = "Tech Lead";
techsDatasource.load(function(){
var relatedTech = techsDatasource.item;
record.Tech = relatedTech;            
});
}
else{} });}


显示所选技术问题的最后一个表的原因是,下拉窗口小部件的值为@datasources.Issues.query.filters.Tech._equals,它会在ValueChange上重新加载问题数据源。

相关内容

最新更新