How to create a change record from UI action on incident form.

Sourab
Kilo Contributor

How to create a change record from a UI action on incident form and pass some details to the change record such as,  short description from the incident form or any other field.

Thanks

1 ACCEPTED SOLUTION

Here is the sample code which maps incident details to change and creates a change record.

var change = new GlideRecord("change_request");
change.initialize();
change.short_description = current.short_description; // incident Short description mapped to change short description.
change.description = current.description;
change.cmdb_ci = current.cmdb_ci;
change.priority = current.priority;
var changesysID = change.insert();
action.setRedirectURL(change);




Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

View solution in original post

11 REPLIES 11

Yes you can re-use existing UI Actions which already have this functionality defined.

If you want the same UI Actions to be visible as form button instead of context menu then modify accordingly.

find_real_file.png

 https://docs.servicenow.com/bundle/quebec-platform-administration/page/administer/list-administrati...


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Sourab
Kilo Contributor

And How can I pass data from incident to that change record

Here is the sample script, here current refers to the current record , if you write this in a incident table, then current will hold incident record

var change = new GlideRecord("change_request");


change.short_description = current.short_description;


change.description = current.description;


change.cmdb_ci = current.cmdb_ci;


change.priority = current.priority;


var sysID = change.insert();

Here is the sample code which maps incident details to change and creates a change record.

var change = new GlideRecord("change_request");
change.initialize();
change.short_description = current.short_description; // incident Short description mapped to change short description.
change.description = current.description;
change.cmdb_ci = current.cmdb_ci;
change.priority = current.priority;
var changesysID = change.insert();
action.setRedirectURL(change);




Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

What if i wanted to open a normal change record?