Copy the Description, Short Description of existing incident record onto the existing problem record

Deepak Shaerma
Kilo Sage
  1. Copy the Description, Short Description of existing incident record onto the existing problem records' description and short description.

8 REPLIES 8

Saurabh Gupta
Kilo Patron
Kilo Patron

Please elaborate your nee.

When you need this.
What is the relation between two tickets?

 

 


Thanks and Regards,

Saurabh Gupta

if the incident is raised on a particular problem , then if we update the description of incident, it will automatically update the description of problem table 

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @Deepak Shaerma 

You can use below code in background script or in fix script

 

var gr = new GlideRecord("incident");
gr.addEncodedQuery("problem_idISNOTEMPTY");
gr.query();
while (gr.next()) {
    var grProb = new GlideRecord("problem");
    grProb.addQuery("sys_id", gr.problem_id);
    grProb.query();
    if (grProb.next()) {
		grProb.description=gr.description;
		grProb.short_description=gr.short_description;
		grProb.update();
    }

}

 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

For Automatic updation you can write Br as below :-

GunjanKiratkar_0-1669193160455.png

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

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

})(current, previous);

Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy