Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

How to set worknotes of Incident from Business rule on Problem

Gayathri5
Tera Guru

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

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

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

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

View solution in original post

5 REPLIES 5

yes

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