how to auto populate CI field in incident with respect to problem it is attached in ServiceNow ?

ashish3020
Kilo Explorer

Hi ,

 

How to auto populate CI field in incident with respect to problem it is attached in ServiceNow ? If I am changing CI field value in problem record then the value of CI field on associated incident also get updated . How to achieve it ?

 

Thank you

2 REPLIES 2

JenniferRah
Mega Sage

You can create an onSubmit client script or a business rule to make that change when the Incident has been saved and the Problem has changed. The business rule would look something like this: 

JenniferRah_0-1757443023408.png

 

JenniferRah_1-1757443042571.png

 

Bert_c1
Kilo Patron

Similar to what Jennifer proposed, include logic to update the incident's CI. The BR would be defined on the 'problem' table. 'Advanced' would be checked, and the following script logic will update the incidents where the 'problem_id' field refers to the problem being updated.  Script on the Advanced tab follows:

 

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

	// Look for incidents referencing this problem, update cmdb_ci there
	var inc = new GlideRecord('incident');
	inc.addQuery('problem_id', current.sys_id.toString());
	inc.query();
	while (inc.next()) {
		inc.cmdb_ci = current.cmdb_ci;
		inc.update();
		gs.addInfoMessage('Incident: ' + inc.number + ' configuration item updated.');
	}

})(current, previous);

 

Or, a client script that runs 'On change' for the problem table and cmdb_ci field that calls a script include with similar logic can work too.