Hide new button of related list based on count

patil uv
Tera Contributor

i have a requirement to hide a new button of related list(outage). onnincident record's related list if we have one outage then new button should be hidden.

4 REPLIES 4

Paul Curwen
Giga Sage

You should be able to do this as follows:  

 

1. Right-click on any column heading on your Related list and Configure=>List control=>Omit New button

2. Check Omit New checkbox

2. Write your script in the Omit New condition Script field (if not on your form configure the form to show it) 

 

If you have never done this before this video is a decent walkthrough of the process: https://www.servicenow.com/community/developer-blog/how-to-hide-new-button-from-related-lists-using-...

 

 

***If Correct/Helpful please take time mark as Correct/Helpful. It is much appreciated.***

Regards

Paul

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Try this in Omit New Button

 

Right click on the list header -> Configure -> list Control

 

var answer;
 if(current.getRowCount() > 0) {
    answer = true;
}
else {
  answer = false;
}

AnuragTripathi_0-1730380016820.png

 

 

 

 

-Anurag

patil uv
Tera Contributor

HI Anurag,

thanks for quick reply. this works fine for native ui. i want to hide new button form related list which is present in service operation workspace.

 

Check my reply here -> Solved: How to hide New Button from a related list in the ... - ServiceNow Community

 

Im not sure if there is a way to put condition there or not.

-Anurag