Make related list visible/hide

VSN
Tera Expert

i have a requirement to hide/show an employee  related list on Company table  in  few scenarios,those are..

if user create New record in employee table it should be in Draft state--- Hide Employee related list.

if user submit the record-- moved to submit state --- Show record 2

if user click on reset to draft --- moved into Draft -- in this case we have to shown Employee Related list.

 

finally 

if new record created in company table-- if record is in Draft -- Hide employee related list.

if  company record is moved to draft  and it is in draft state then show Employee related list,

2 REPLIES 2

Danish Bhairag2
Tera Sage
Tera Sage

Hi @VSN ,

 

Plz add these code in ur condition whenever it satisfies. Use on load script for the same.

 

https://www.servicenow.com/community/csm-forum/how-to-hide-related-list-based-on-condition/m-p/40772...

 

Thanks,

Danish

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @VSN,

 

You can create a onchange client script and use showRelatedList() and hideRelatedList() to show and hide related list based on conditions.

 

Example Script :

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   var brkGlass = g_form.getValue('u_break_glass'); //Assuming u_break_glass is the exact column value
   if(brkGlass == 'yes'){ //Replace yes with the exact choice value of the field breadk glass
   g_form.showRelatedList("BreakGlassRequests"); //Make sure you pass the name of the related list
}else{
   g_form.hideRelatedList("BreakGlassRequests"); //Make sure you pass the name of the related list
}
}

☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect