- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2022 07:56 PM
Hello,
I would like to set the state on the incident record to "Awaiting Change" when a Change is created from an incident, by updating the existing "Create Normal Change" UI action.
Please guide me through this.
Solved! Go to Solution.
- Labels:
-
Change Management
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2022 09:16 PM
Actually I have created an "awaiting change" choice in the state field itself. And below solution worked for me.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2022 09:18 PM
Can you please share your full code?
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2022 09:19 PM
(function(current, previous, gs, action) {
var stdChgCatalogActive = GlidePluginManager.isActive("com.snc.change_management.standard_change_catalog");
if (stdChgCatalogActive) {
var target = {};
target.table = current.getTableName();
target.sysid = current.getUniqueValue();
target.field = 'rfc';
try {
target.isWorkspace = (typeof RP == 'undefined');
}
catch (err) {
target.isWorkspace = false;
}
gs.getSession().putProperty('change_link', target);
}
var changeRequest = ChangeRequest.newNormal();
changeRequest.setValue("short_description", current.short_description);
changeRequest.setValue("description", current.description);
changeRequest.setValue("cmdb_ci", current.cmdb_ci);
if (changeRequest.hasValidChoice('priority', current.priority))
changeRequest.setValue("priority", current.priority);
changeRequest.setValue("sys_domain", current.sys_domain);
changeRequest.setValue("company", current.company);
var sysId = changeRequest.insert();
current.setValue('state',4);
current.update();
if (!stdChgCatalogActive) {
current.rfc = sysId;
current.update();
var incUrl = "<a href='" + current.getLink(true) + "'>" + current.getDisplayValue() + "</a>";
gs.addInfoMessage(gs.getMessage("Normal Change {0} created from {1}", [changeRequest.getValue("number"), incUrl]));
}
action.setReturnURL(current);
action.setRedirectURL(changeRequest.getGlideRecord());
})(current, previous, gs, action);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2022 09:24 PM
Try this.
(function(current, previous, gs, action) {
var stdChgCatalogActive = GlidePluginManager.isActive("com.snc.change_management.standard_change_catalog");
if (stdChgCatalogActive) {
var target = {};
target.table = current.getTableName();
target.sysid = current.getUniqueValue();
target.field = 'rfc';
try {
target.isWorkspace = (typeof RP == 'undefined');
}
catch (err) {
target.isWorkspace = false;
}
gs.getSession().putProperty('change_link', target);
current.setValue('state',4);
current.update();
}
var changeRequest = ChangeRequest.newNormal();
changeRequest.setValue("short_description", current.short_description);
changeRequest.setValue("description", current.description);
changeRequest.setValue("cmdb_ci", current.cmdb_ci);
if (changeRequest.hasValidChoice('priority', current.priority))
changeRequest.setValue("priority", current.priority);
changeRequest.setValue("sys_domain", current.sys_domain);
changeRequest.setValue("company", current.company);
var sysId = changeRequest.insert();
if (!stdChgCatalogActive) {
current.rfc = sysId;
current.setValue('state',4);
current.update();
var incUrl = "<a href='" + current.getLink(true) + "'>" + current.getDisplayValue() + "</a>";
gs.addInfoMessage(gs.getMessage("Normal Change {0} created from {1}", [changeRequest.getValue("number"), incUrl]));
}
action.setReturnURL(current);
action.setRedirectURL(changeRequest.getGlideRecord());
})(current, previous, gs, action);
Please mark this helpful/correct, if applicable.
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2023 02:59 AM
Thank you Vishwa Pandya !