Populate values in journal field

neharao
Giga Contributor

Hi all,

I have a requirement where i need to populate the CI ´s from Affected CIs tab into the journal field (Additional comments) . Please find the screen shot below.

find_real_file.png

Kindly let me know how to proceed on this.

Thanks,

Neha

1 ACCEPTED SOLUTION

Please use below script in your business rule.



var aff = new GlideRecord('task_ci');


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


  aff.query();


  gs.log("No of records " + aff.getRowCount());


  while(aff.next()){



  current.work_notes = aff.ci_item.getDisplayValue();


  //current.update();



  }


View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Neha,



Following is the script. you will have to modify changes as per your need



var journalVal = 'Sample comments';


var fieldName = 'comments';


var incRec = new GlideRecord("change_request");


  incRec.addQuery("number", "CHG0000015");


  incRec.query();


  if(incRec.next()){


  incRec[fieldName].setJournalEntry(journalVal);


  incRec.update();


  }



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

sachin_namjoshi
Kilo Patron
Kilo Patron

You can write business rule to iterate through records in afffected CI related list and append in additional comments field.



Regards,


Sachin


neharao
Giga Contributor

Hi all,



Thanks for all your replies. I am actually able to populate single value from Affected CIs to Journal field. Can anyone kindly guide me how to populate all the values in the affected CIs to the Journal field. Please find the script and screen shot below.



var incnumber=current.sys_id;


var curr="0c441cfdc61122750182c132dd03ab88";


var lookup=new GlideRecord("task_ci");                 // task_ci is the affected cis table


  lookup.initialize();


  lookup.task=incnumber;


  lookup.ci_item=curr;// task field holds incident number in OOB


  var ci = lookup.ci_item;


  var cidisp = ci.getDisplayValue();


    lookup.insert();  


  current.u_journal =ci.getDisplayValue();



With the above script i am able to push only one value in the jounal field.



find_real_file.png


find_real_file.png


                                                                                                                                                   



If anyone knows on this kindly guide me.



Thanks,


Neha


Please use below script in your business rule.



var aff = new GlideRecord('task_ci');


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


  aff.query();


  gs.log("No of records " + aff.getRowCount());


  while(aff.next()){



  current.work_notes = aff.ci_item.getDisplayValue();


  //current.update();



  }