Virtual Agent in MS Teams: multiple delegates are set - only one receives the approval notification
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
40m ago - last edited 25m ago
If a user sets multiple delegates for approvals over the same time range, all of them should receive the approval notification in Virtual Agent via MS Teams. They don't, because of a bug in getDelegatesForUser() in the MSTeamsNotificationBuilderUtilSNC Script Include. For example, if you delegate your approvals to User1, User2, and User3, the method returns an array like [User1, User1, User1] instead of the three distinct delegates. The script pushes the reference element (delegateGr.delegate) into the array instead of its sys_id value:
getDelegatesForUser: function(userId) {
var ids = [];
var delegateGr = new GlideRecord("sys_user_delegate");
var currentDateTime = new GlideDateTime();
delegateGr.addQuery("starts", "<=", currentDateTime);
delegateGr.addQuery("ends", ">=", currentDateTime);
delegateGr.addQuery("approvals", true);
delegateGr.addQuery("user", userId);
delegateGr.query();
while (delegateGr.next()) {
// put all delegate users in array and return
ids.push(delegateGr.delegate);
}
return ids;
}
Workaround: override the method in MSTeamsNotificationBuilderUtil, which extends the SNC Script Include:
getDelegatesForUser: function(userId) {
var ids = [];
var delegateGr = new GlideRecord("sys_user_delegate");
var currentDateTime = new GlideDateTime();
delegateGr.addQuery("starts", "<=", currentDateTime);
delegateGr.addQuery("ends", ">=", currentDateTime);
delegateGr.addQuery("approvals", true);
delegateGr.addQuery("user", userId);
delegateGr.query();
while (delegateGr.next()) {
// put all delegate users in array and return
ids.push(delegateGr.delegate.sys_id.toString());
}
return ids;
}
The only change is on the ids.push(...) line, which now pushes the sys_id as a string.
0 REPLIES 0
