- 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 08:03 AM
Thanks Tim & Sachin, I think the script include should be returning the correct value, my issue is with the condition on the UI Action now... do you know the proper syntax to call it and pass the current_assigned.to through?
Here is the current condition on the UI Action:
I've tried to add a few different combinations:
|| isDelegate(current.assigned_to))
|| new isDelegate(current.assigned_to))
|| isDelegate(current.assigned_to) == true)
|| new isDelegate(current.assigned_to) == true)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2018 08:20 AM
Can you add this as the first line inside the initialize function of the script include? gs.log('in isDelegate, serOwnrVal: ' + serOwnrVal);
That will tell us if the SI is getting the right user value.
Also add this to your script include right before each of the "return" lines:
gs.log('isDelegate returning: ' + [true/false]);
Visit the change request form and then check System Logs for "isDelegate". That will let us know if the isDelegate script is trying to return a value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2018 09:34 AM
I have validated that serOwnrVal is passing the correct sys_id for the current.assigned_to and that the value coming back is true. I also tested one where it should be false, and it returned false. However, the UI Action button still does not appear. Here is the condition being used now:
The SI (client callable) is currently:
I also tried:
new isDelegate(current.assigned_to) == true) as the condition, same result.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2018 10:47 AM
What is the current State of the change request you're working with? If the script include is returning TRUE and the button isn't showing up, you should look at the other conditions. My current idea is that the "next state" is not Implement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2018 10:54 AM
That's what has me so stumped ... the current state is Scheduled, so the next state is Implement which is correct. Even if I put "new isDelegate(current.assigned_to)" as the only condition, the script returns true, and still does not display the UI Action button.