hide or show a related list.

ravigajananjosh
Mega Contributor

I have a requirement on Incident table to hide or show a related list. I have introduced a new choice field on Incident - BreakGlass which has choices Yes or No. Also I have a Related list on Incident i.e BreakGlassRequests which lists all break glass requests done for that incident. What should happen is untill I take Yes in BreakGlass field the BreakGalssRequests related should be hidden. I tried this function onCondition() { g_form.showRelatedList(BreakGlassRequests); } in UI policies in SCripts but thats not working. Can some one help me with this?

9 REPLIES 9

Hi Ravi,



Since you are writing an On Change client Script, you need to select the correct field name which in your case should be "Break Glass" instead of Active as per your screen shot.



Have highlighted the portion where you need to select the correct field name and instead of using myValue as a variable you can directly use newValue as below:


find_real_file.png




Please modify your script as below:



Script:



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


    if (isLoading || newValue === '') {


      g_form.hideRelatedList("task_sla.task");                     // Replace your Related List here instead of task_sla.task


          return;


    }


  if(!g_form.isNewRecord())


  {


  if(newValue =='Yes')


  {


  g_form.showRelatedList("task_sla.task");


  }


  else if(newValue == 'No')


  {


  g_form.hideRelatedList("task_sla.task");


  }


  }




    //Type appropriate comment here, and begin script below


   


}



find_real_file.png



Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

No mate didn't work. Here are the screenshots.




sernow1.png.jpg



sernow2.png.jpg


Hi,



Can you check your Related List Name(You need to pass the backend name of your Related LIst) and try the same code again. To check the Related List name follow the below steps:



1) Navigate to "Related List" module under System UI and search as Table=incident as shown below:



find_real_file.png



2) Open the Record with View as Default or the one in which your Related List is present.


3) Scroll Down and check the name of your Related List entries and copy the same and try the code again.



find_real_file.png



Above code shared is working for me as per your requirement.



Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Shloke ! Mate you rock. This worked at last. Thanks for all your efforts.


Awesome!!. Please mark the response as correct so that the thread can be closed and this question can be removed from the Unanswered List. Please find the below link on how to mark the answer as correct in community:



How To Mark Answers Correct From Community Inbox



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke