The CreatorCon Call for Content is officially open! Get started here.

How to grayed out the New, Edit Buttons in Child incidents Tab

harinya
Tera Contributor

HI 
Can some one please help on this below requirement, 
I want to grayed out the Buttons (New, Edit) in child incidents tab , if the current incident that i opened is a child (in simple user can't add child to another child incident)
If for example, Inc123 is a child incident and if i open that Inc123 below New and Edit buttons should be Grayed out in child incidents tab

harinya_0-1713952509155.png

Thanks in Adnvance

 

4 REPLIES 4

Mark Manders
Mega Patron

Why not create a UI policy to hide the related list when it's a child incident? You will never have childs on childs, so why show it? 
An example can be found here: https://www.servicenow.com/community/developer-forum/how-to-hide-a-related-lists-based-on-certain-co...
Next to that: you can hide the buttons, but not gray them out, as far as I know.

 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Thanks for Response , it was Really Helpful

Community Alums
Not applicable

Hi @harinya ,

I tried your problem in my PDI and it's works for me

Right click on header of related list and open List Control

SarthakKashya2_0-1713958539847.png

 

Add below code in Omit New Condition and Omit Edit Condition

SarthakKashya2_2-1713958647162.png

var answer ;
gs.log("Checck log incidnet 111 = " + current.sys_id);
gs.log("Checck log incidnet 222 = " + parent.child_incidents);

if (parent.child_incidents <= 0) { //Do not remove the 'New' button
   answer = false ;
}
else { //Remove the 'New' button
   answer = true ;
}

answer ;

 

Please mark my answer correct and helpful if this works for you

 

Thanks and Regards 

Sarthak

 

 

 

Thanks for Response