- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2018 12:25 PM
I am trying to show an "Implement" UI Action button on a Change request to either an admin, the user that is the current assigned to, or a user who is the delegate of the current assigned to. I tried using the getMyAssignments() function from the getMyApprovals business rule, but I'm not able to get it to work properly. What do I need to add to this condition statement to allow for delegates to see/invoke the button:
(gs.hasRole('admin') || current.assigned_to == gs.getUserID())
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2018 07:46 AM
The following changes ended up with a workable solution! Here is the UI Action condition: new isDelegate().delegatecheck(current.assigned_to))
Script Include:
var isDelegate = Class.create();
isDelegate.prototype = {
initialize: function() {
},
delegatecheck : function (serOwnrVal){
var grDelegate = new GlideRecord("sys_user_delegate");
grDelegate.addQuery("user", serOwnrVal);
grDelegate.addQuery("delegate", gs.getUserID());
grDelegate.addQuery("assignments", "true");
grDelegate.addQuery("starts", "<=", gs.daysAgo(0));
grDelegate.addQuery("ends", ">=", gs.daysAgo(0));
grDelegate.query();
{
if(grDelegate.next()){
answer = true;
return answer;
}
else{
answer = false;
return answer;
}
}
},
type: 'isDelegate'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2018 10:57 AM
Is there another UI Action on this table (or task) that has the same "Action Name"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2018 11:26 AM
No, the action name is unique on both the change_request and task table (state_model_move_to_implement).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2018 07:46 AM
The following changes ended up with a workable solution! Here is the UI Action condition: new isDelegate().delegatecheck(current.assigned_to))
Script Include:
var isDelegate = Class.create();
isDelegate.prototype = {
initialize: function() {
},
delegatecheck : function (serOwnrVal){
var grDelegate = new GlideRecord("sys_user_delegate");
grDelegate.addQuery("user", serOwnrVal);
grDelegate.addQuery("delegate", gs.getUserID());
grDelegate.addQuery("assignments", "true");
grDelegate.addQuery("starts", "<=", gs.daysAgo(0));
grDelegate.addQuery("ends", ">=", gs.daysAgo(0));
grDelegate.query();
{
if(grDelegate.next()){
answer = true;
return answer;
}
else{
answer = false;
return answer;
}
}
},
type: 'isDelegate'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2018 12:43 PM
The getMyAssignments function is a good start, but you would want to add 'g.addQuery("user", current.assigned_to);' and maybe adjust 'g.addQuery("assignments", "true");' if necessary.