- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2017 07:54 AM
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.
Kindly let me know how to proceed on this.
Thanks,
Neha
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2017 08:41 AM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2017 07:59 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2017 08:00 AM
You can write business rule to iterate through records in afffected CI related list and append in additional comments field.
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2017 12:26 AM
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.
If anyone knows on this kindly guide me.
Thanks,
Neha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2017 08:41 AM
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();
}
