- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 12:25 AM
Hi
(function executeRule(current, previous /*null when async*/ ) {
var gp = new GlideRecord('problem');
gp.addQuery('sys_id', current.sys_id);
gp.query();
while (gp.next()) {
}
var gr = new GlideRecord('incident');
gr.addQuery('problem_id', gp.sys_id);
gr.query();
while (gr.next()) {
gr.setValue('u_cause_code', '14');
gr.setValue('description', 'set from problem BR');
gr.setValue('work_notes','Incident closed by'+ gp.number);
gr.update();
}
})(current, previous);
I am trying set the work_notes in a similar way but it is not working.
I want to set my worknotes as "Incident closed by PRBxxxxx";
How can we set Incident worknotes in the above code?
Regards,
Gayathri
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 12:39 AM
Hi,
update as this which is optimized
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('incident');
gr.addQuery('problem_id', current.getUniqueValue());
gr.query();
while (gr.next()) {
gr.setValue('u_cause_code', '14');
gr.setValue('description', 'set from problem BR');
gr.work_notes = 'Incident closed by' + current.number;
gr.update();
}
})(current, previous);
Regards
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
03-07-2022 12:28 AM
Hi,
Try like below..
gr.work_notes = 'Incident closed by'+ gp.number;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 12:31 AM
If still not working...
then add the below line after while (gp.next()) {
var number = gp.number;
Next, after gr.setValue line add below line
gr.work_notes = 'Incident closed by'+number;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 12:39 AM
Hi,
update as this which is optimized
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('incident');
gr.addQuery('problem_id', current.getUniqueValue());
gr.query();
while (gr.next()) {
gr.setValue('u_cause_code', '14');
gr.setValue('description', 'set from problem BR');
gr.work_notes = 'Incident closed by' + current.number;
gr.update();
}
})(current, previous);
Regards
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
03-07-2022 01:18 AM
Hi,
It is working.
current.sys_id and current.getUniqueValue() both will fetch sys_id na, we can use any right?