- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2024 10:01 AM
Hello I am having an issue with a ui action condition I am trying to work on. the UI Action should only show when The task has an active approval record tied to it. however when I try to add my function from my script include the button never shows. I believe my logic is correct but I'm not seeing any issues.
Here is my script include script( client callable checked)
var ApprovalChecker = Class.create();
ApprovalChecker.prototype = {
initialize: function() {},
hasApprovals: function(recordSysId) {
var approval = new GlideRecord('sysapproval_approver');
approval.addQuery('document_id', recordSysId);
approval.addQuery('state', 'requested');
approval.query();
return approval.hasNext(); // Returns true if there are any approvals, false otherwise
},
type: 'ApprovalChecker'
};
And here is the condition of the ui action
Any assistance would be helpful.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2024 10:07 AM
Looking at your condition, you are providing current as input? Though you are not using current in your Script Include? Shouldn't you provide current.getUniqueValue() or current.sys_id as input?
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2024 10:04 AM
Hi there,
Did you try adding any debugging? For example is the recordSysId valid and what you would expect? Is the return returning what you would expect? Or is the script perhaps failing?
Adding debugging could help show the issue within a few seconds.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2024 10:07 AM
Looking at your condition, you are providing current as input? Though you are not using current in your Script Include? Shouldn't you provide current.getUniqueValue() or current.sys_id as input?
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2024 10:11 AM
You are correct. I didnt even notice I had done that . changing it to current.sys_id did the trick thank you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2024 10:08 AM
Just verified on a PDI, indeed the input you are providing is at least an issue. Change it as I mentioned in my previous reply.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field