Mandatory related list

karshauliya
Kilo Contributor

I would like to make mandatory

1 ACCEPTED SOLUTION

shloke04
Kilo Patron

Hi,



In order to make the Related List Mandatory i.e. checking if any record is present in the Related List or not we can make use of an Before Update Business Rule and Abort the Form Submission as required. Please follow the below steps:



1) For Example On the Incident Form, I have the Problem Related List and say based on certain condition you want to check whether the Problem Related List has Records attached or not whether a New one or an existing one then we can have the below script and make the Related List as a mandate one:



Script:



(function executeRule(current, previous /*null when async*/) {




  // Add your code here


  var prb = new GlideRecord("problem");


  prb.addEncodedQuery("parent=" + current.sys_id);


  prb.query();


  if(!prb.next())


  {


  gs.addInfoMessage("Please link a Problem Record at the bottom Probem Tab");


  action.setRedirectURL(current);


  current.setAbortAction(true);



  }




})(current, previous);




find_real_file.png



find_real_file.png



Result:



If the User tries to Update the Record without attaching the Problem Record it aborts the form submission with the Invalid Update Error as shown 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

View solution in original post

13 REPLIES 13

Karthik Reddy T
Kilo Sage

Refer below threads may helpful to you.



Make entry in related list mandatory



how to make a field mandatory, if entry is made in related list..?



make related list tab mandatory


Karthik Reddy T.
ServiceNow Commnunity MVP -2018 class.

snehabinani26
Tera Guru

Hi,



You will be able to do this via a data policy on the table of the embedded list - you will however not be able to see the mandatory fields visually in the embedded list it self, as UI policies are not evaluated in list views - you will however get a Data Policy Exception when saving the form, if the mandatory fields have not been filled out.


So it is not so user friendly.


The data policy it self, can include values from the parent record in its condition to determine when the fields should be mandatory.


Here is an example where I have created a simple table which has a reference to the incident table, and one of the fields are mandatory, based on a condition which looks at both the parent incident, and the embedded table it self.



find_real_file.png


vinitha3
Tera Guru

Hi,



What is the exact requirement?


But you can find the answer here,


You may need to create a script include and client script.



Make entry in related list mandatory



Thanks,


Vinitha.K


Vinitha,



In change module , verification is the related list. i would like verification to be mandatory.



Related list.png