Control Visibility of Related List Action "New" button based on Form Data

Matt Cordero1
Tera Guru

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:

MattCordero1_0-1744029098260.png

 

7 REPLIES 7

Matt Cordero1
Tera Guru

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!!

@Matt Cordero1 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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