Converting Incidents to Change Requests

Johnathan Herre
Kilo Contributor

I am trying to create a form UI Action that will add the option of converting an Incident into a change request.  I would like for the following flow.

1. "Convert to Change" listed under the form context menu.

2. On click of "Convert to Change"  a warning pops up that states, "Incident will Close and a Change will be created."

3. Incident closes upon clicking continue.

4. Change is created with all of the fields that the incident has.  ex: short description, Comments, priority, requestor, category, subcategory, etc...

 

We want the incident to close automatically once you accept the convert to change operation.  Any help with this would be greatly appreciated.

 

3 REPLIES 3

puneetgoels1
Tera Guru

The flow looks correct. You can code the same in UI Action. Your post doesn't say what kind of help are you looking form

sachin_namjoshi
Kilo Patron
Kilo Patron

-You will have to create UI action  named as "Convert to Change" on incident table.

- Please use below code in your UI action

if (confirm('Incident will Close and a Change will be created')){

var changeRequest = ChangeRequest.newNormal();
	changeRequest.setValue("short_description", current.short_description);
	changeRequest.setValue("description", current.description);
	changeRequest.setValue("cmdb_ci", current.cmdb_ci);
	changeRequest.setValue("priority", current.priority);
	changeRequest.setValue("sys_domain", current.sys_domain);
	changeRequest.setValue("company", current.company);
	changeRequest.insert();
	current.state = "7";
	current.rfc = changeRequest.getGlideRecord().getUniqueValue();
	current.update();
	gs.addInfoMessage(gs.getMessage("Change {0} created", changeRequest.getValue("number")));
	action.setRedirectURL(changeRequest.getGlideRecord());
	action.setReturnURL(current);

}

 

Regards,

Sachin

I have some odd behaviour with this code.  When I click on "Convert to Change"  I do not get prompted.  It refreshes the form and does not create a change or close the incident.  the biggest thing I am trying to accomplish is getting all of the information into the change that was in the incident, and then having the incident close.