Control Visibility of Related List Action "New" button based on Form Data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 05:32 AM
I have a Related List and I am trying to restrict the visibility of the OOB "New" button, based on the form's status ("Draft" or "Rejected to Draft"). I have tried applying Data Conditions on the Create ACL for the table, but adding any Data Condition hides the "New" button completely. What is the proper method to hide the "New" button on the Related List so it only appears when form's status is "Draft" or "Rejected to Draft"?
NOTE: This is within a Scoped Application.
Screenshot:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 08:26 AM
All, I am looking for a solution within a Scoped Application.
For example, the below solution works with the ITIL form, on the table.
var answer = true; // Omit the button
var gr = new GlideRecord("table");
gr.addQuery('sys_id', parent.sys_id);
gr.addEncodedQuery('status=draft^ORstatus=rejected_to_draft');
gr.query();
if (gr.next()) {
answer = false; // Show the button
}
//gs.info("Final Answer: " + answer);
The above DOES NOT work in a Scoped Application.
Any help would be greatly appreciated!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 08:37 AM
where did you write this script?
Did you add logs and see what came?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 10:40 AM
Hello @Matt Cordero1 ,
Did you see the solution I provided yesterday? You don't need to write a GlideRecord query, all you need is a single line to describe the condition for hiding the New button. I have updated my reply with the field name and values so you can basically copy and paste it. This works in scoped and non-scoped applications.
Regards,
Robert