- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2016 03:25 AM
Hi guys!
We added a few new change types using this guideline: Add a new change type
This works just fine until we want to create a change from an incident.
I would like to make a new UI action for each new change type (so it can be used/clicked from the "form context menu") using the (OOB) script from "Create Normal Change" - lets call this new change-type : Infrastructure_server. The only difference between Normal-change and Infrastructure_server-change is the workflow behind. So same fields on the change-form etc.
(function(current, previous, gs, action) {
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.rfc = changeRequest.getGlideRecord().getUniqueValue();
current.update();
gs.addInfoMessage("Change " + changeRequest.getValue("number") + " created");
action.setRedirectURL(changeRequest.getGlideRecord());
action.setReturnURL(current);
})(current, previous, gs, action);
---
The problem is this line...where ServiceNow (Helsinki) create a new object using "newNormal()".
var changeRequest = ChangeRequest.newNormal();
I want to make something like this..:
var changeRequest = ChangeRequest.newInfrastructure_server();
When I look into the "script includes" the script "ChangeRequestSNC" is the only place where "newNormal()" is defined by this lines (302-304):
ChangeRequestSNC.newNormal = function() {
return ChangeRequestSNC.newChange(ChangeRequest.NORMAL);
};
...but this script include is read-only...
So how could I add a new change-type to the "create change functionality from incidents" ?
Thanks!
Soeren
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2016 04:17 AM
Hi,
Did you go through the link Add a new change type that explains how to add your own Change Type. You need to ensure that you create a Workflow and specify the condition in the Workflow appropriately so that it gets attached to the Change_Request records when type = INFRASTRUCTURE_SERVER.
Refer to step 6 "Create a workflow for the new change request type." in the link Add a new change type.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2017 08:22 AM
Hi all,
In the end I decided to create a new change request glide record, and set the change type myself. Please see code below.
function(current, previous, gs, action) {
var changeRequest = new GlideRecord('change_request');
changeRequest.initialize();
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.setValue("type", 'expedited');
current.rfc = changeRequest.insert();
current.update();
gs.addInfoMessage("Change " + changeRequest.getValue("number") + " created");
action.setRedirectURL(changeRequest);
action.setReturnURL(current);
})(current, previous, gs, action);
I hope it helps! Any feedback is welcome
Cheers,
Robert