Related list field populated on a form field

Abinash
Kilo Contributor

I have this impacted services related list in my incident form.

I want the "managed by" field which is a reference field of user table to be populated to a custom field in my INC form. Kindly help me to

achieve this. Developer Community bawiskar

Thanks in advance

find_real_file.png

1 ACCEPTED SOLUTION

Not sure how you are going to pull that off but here is code for adding users to a list field that relates to the sys_user table. Adding or removing an Affected CI in the related list will trigger an update of the List field and add assigned to from all the related CI's to the u_service_owner field.



List field on Incident table called u_service_owner referencing sys_user table.


Business rule on task_ci table. Runs after on Insert, Update and Delete.



Script:


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



  // Add your code here


  var inc = new GlideRecord('incident');


  inc.addQuery('sys_id',current.task);



  inc.query();


  if(inc.next()){


  inc.u_service_owner=''; //Clear service owner list



  var ci = new GlideRecord('task_ci');


  ci.addQuery('task',current.task);


  ci.query();


  while (ci.next()){


  inc.u_service_owner   += ',' + ci.ci_item.assigned_to;   //Add CI assigned to



  }



  inc.update();


  }


 


})(current, previous);


View solution in original post

27 REPLIES 27

Abinash
Kilo Contributor

Hi balaji,


I tries with the above code but still no luck.


So i generally tried out on a demo instance where i have a field called "serial no" which stores the related list "Task sla"'s "SLA defination" field.


heres the code. used the same concept still not working



find_real_file.png


Can i know,


is contract_sla field is there or not????



if you are trying in demo instance right, if you give your dev instance name and login credentials i will look that issue.


Abinash
Kilo Contributor

plesae share me ur email id.. i will provide you my credentials there


br.balaji25@gmail.com



send your instance number, login credentials.


Can i know which filed label need to populate in serial number field ???????



check your are business rule as well, your expecting the same answer? if not specify field label need to populate in serial number field