我设置了仪表板,但只能获取技术人员和每个技术人员的总凭单。我想在仪表板上获取每个技术人员的开放票和封闭票。
var allRecords = app.models.Tickets.newQuery().run();
var stats = {};
for(var i = 0; i < allRecords.length; i++) {
var recordType = allRecords[i].technician;
if(!stats[recordType]) {
stats[recordType] = 0;
}
stats[recordType]++;
}
var records = [];
var properties = Object.getOwnPropertyNames(stats);
for(var j = 0; j < properties.length; j++) {
var record = app.models.CalculatedDb.newRecord();
record.Tech = properties[j];
record.Count = stats[properties[j]];
records.push(record);
}
return records;
}