Copy Description from the Problem to Incidents

Community Alums
Not applicable

Hi,

I am working on a scenario where the Description field from a Problem record will be copied to associated incident records once the problem record is saved. I have done everything but the Description in Incident records is not getting updated with the Description of the problem record once is saved the problem record. Kindly help.

 

1.png

 

2.png

 

3.png

 

4.png

 

5.png

 

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

	var gr = new GlideRecord("incident");
	gr.addQuery('problem_id', '3D62304320731823002728660c4cf6a7e8');
	gr.query();
	while(gr.next()){
		gr.description = current.description;
		gr.update();
	}

})(current, previous);

 

Regards

Suman P.

1 ACCEPTED SOLUTION

Abhishek_Thakur
Mega Sage

Hello @Community Alums ,

You need to create a BR on after insert/Update on problem table and follow the below script that will help you. I tried in my PDI it is working as expected.

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

	// Add your code here
	var inc = new GlideRecord("incident");
	inc.addQuery("problem_id",current.sys_id);
	inc.query();
	if(inc.next()){
		inc.description=current.description;
	}
	inc.update();

})(current, previous);

 

Please mark my answer as accepted solution and give thumbs up, if it helps you.

View solution in original post

5 REPLIES 5

Community Alums
Not applicable

Hi @Abhishek_Thakur,

I am passing directly the sys id instead of the current.sys_id, why do you think it is wrong?

Regards

Suman P.