Script Include return value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2016 03:51 PM
Hi,
I have requirement if any one of the approval request for change is approved then doesn't show UI Action on form. I have written Script Include and checking all the approval requests for change and if any of state is approved return false otherwise return true but it's always returning True even one of the approval request is approved
Script Include:
UI Action:
I am checking this return value by System Logs. Is there anything i am missing here?
Thanks,
Chaitanya

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2016 04:54 PM
for your requirement you don't even need a script include.
Just in the condition put current.state == 'approved' and if you want this button to show only to CAB members then use either script include or role if there is one only to CAB members
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2018 02:47 AM
Hey, Hi , I have a similar sort of requirement, where I need to show Close UI action only to requester and Change Aprrovers, can you help me with the script include for this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2016 05:11 PM
Assuming that you can't use dvp's suggestion, your code seems to have a few logical errors.
All you need to do is this:
checkApproval: function() {
var changeId = this.getParameter('sysparm_changeid'); //sys_id
var approverGr = new GlideAggregate('sysapproval_approver');
var numOfApproved = 0;
approverGr.addQuery('document_id',changeId);
approverGr.addQuery('source_table','change_request');
approverGr.addQuery('state','approved');
approverGr.addAggregate('COUNT');
approverGr.query();
if ( approverGr.next() ) {
numOfApproved = approverGr.getAggregate('COUNT');
}
gs.print(numOfApproved);
return (numOfApproved >= 1)
}
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2016 05:46 PM
You should not be using client callable script include here. Condition field will use server side script. Post your script include here instead of a screenshot so that I can edit the code