- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 12:07 PM
On our Case table, we have a UI Action called 'Create Incident'. I would like to update the script so it passes the values in the 'Service' field (u_service) and 'Assignment Group field (assignment_group) on the Case to the newly created Incident.
Here's the script currently. How would I add the additional values?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 12:38 PM
Use below code to update these custom fields.
createIncidentFromCase: function(caseGr, uiActionHandler) {
var incGr = new GlideRecord("incident");
var ep = new GlideScriptedExtensionPoint().getExtensions(ServiceManagementIntegrationConstants.CASE_INC_EXTENSION_POINT);
//If there is any other new extension instance other than the OOB one, concat them together
//The extension instance with higher order number would overwrite the one with lower order number
for(var i = 0; i < ep.length; i ++){
var point = ep[i];
point.copyFieldsFromCaseToIncident(incGr, caseGr);
}
var incSysId = incGr.insert();
var inc = new GlideRecord('incident');
inc.addQuery('sys_id',incSysId);
inc.query();
while(inc.next()){
inc.cmdb_ci = current.u_service;
inc.assignment_group = current.assignment_group;
inc.update();
}
caseGr.incident = incSysId;
caseGr.update();
gs.addInfoMessage(gs.getMessage("Incident {0} created", incGr.number));
uiActionHandler.openGlideRecord(incGr);
uiActionHandler.setReturnURL(caseGr);
},
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 12:38 PM
Use below code to update these custom fields.
createIncidentFromCase: function(caseGr, uiActionHandler) {
var incGr = new GlideRecord("incident");
var ep = new GlideScriptedExtensionPoint().getExtensions(ServiceManagementIntegrationConstants.CASE_INC_EXTENSION_POINT);
//If there is any other new extension instance other than the OOB one, concat them together
//The extension instance with higher order number would overwrite the one with lower order number
for(var i = 0; i < ep.length; i ++){
var point = ep[i];
point.copyFieldsFromCaseToIncident(incGr, caseGr);
}
var incSysId = incGr.insert();
var inc = new GlideRecord('incident');
inc.addQuery('sys_id',incSysId);
inc.query();
while(inc.next()){
inc.cmdb_ci = current.u_service;
inc.assignment_group = current.assignment_group;
inc.update();
}
caseGr.incident = incSysId;
caseGr.update();
gs.addInfoMessage(gs.getMessage("Incident {0} created", incGr.number));
uiActionHandler.openGlideRecord(incGr);
uiActionHandler.setReturnURL(caseGr);
},
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 12:56 PM
Thanks! Looks like I will have to contact ServiceNow for this. It's showing this script include is read-only.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 01:26 PM
You can create your own script include with these updates and call this script include from UI action.
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 01:32 PM
So, I would just create a new script include and only enter the code above? But, I would need to create a new UI Action called something different than 'Create Incident', correct?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2020 01:42 PM
No need to create new UI action.
Just create new script include and copy code from OOB script include and call this script include your UI action.
Regards,
Sachin