Script to make related list entry mandatory

sravya03
Tera Contributor

I have a requirement to make sure incident pending change related list tab on change request form  is mandatory when emergency breakfix is  ABC and classification is DEF or classification changes to DEF.

 

I have written below code on change table using before business rule (update ) with filter conditions as priority 1 ,breakfix as ABC and classification as DEF

 

(function executeRule(current, previous /*null when async*/) {
  var inc = new GlideRecord("incident");
  inc.addQuery("parent", current.getUniqueValue()); // set the condition
  inc.query();
  if(!inc.hasnext())
  {
  gs.addErrorMessage(" reject ");
  current.setAbortAction(true);
}
 })(current, previous);
 
It is throwing the error message but classification value is changing from DEF to xxx(previous value) after adding incident to the related tab.
 
Pls help in fixing the issue.
0 REPLIES 0