UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2025 11:41 PM
Hello all,
I have created a Cancel UI action button on the form,
i) this button should be visible only when all the related tasks of that particular record are closed, if any one task record is in open state then the button should not be visible and
ii) once the record is Cancelled the Cancel UI action button should not be visible.
I attached the screenshot of the code which i wrote , suggest with best methods
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2025 03:47 AM
Hi @BhupathiC,
the view conditions are set out of the script field, can you share that as well?
and also, what's the current behaviour? is the button displayed always or never....?
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2025 07:48 AM
Hi @BhupathiC ,
This is best done using the UI Action’s Condition field server-side.
There is condition field there you can enter below code snippet.
if (current.state == 'Cancelled') {
answer = false;
return;
}
var taskGR = new GlideRecord('change_task');
taskGR.addQuery('change_request', current.sys_id);
taskGR.addQuery('state', '!=', 3); // Assuming '3' is Closed
taskGR.query();
answer = !taskGR.hasNext(); // Show if no open tasks
Try it out!
Thanks,
Bhimashankar H
-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2025 08:30 PM
Hey @BhupathiC ,
I hope you saw my reply.
Did you get chance to try it out. If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. It will help future readers as well having similar kind of questions and close the thread.
Thanks,
Bhimashankar H