- 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
‎10-26-2016 03:34 AM
The script include "ChangeRequest" extends from "ChangeRequestSNC". While "ChangeRequestSNC" is protected from updates, you can modify the code in "ChangeRequest" script include. You can add the function for the new Change Type in "ChangeRequest" script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2016 03:41 AM
Hi Aditya
How... like this? (new lines marked with bold).. Tried it, but then it doesn'tn add the workflow...
var ChangeRequest = Class.create();
ChangeRequest.NORMAL = "normal";
ChangeRequest.STANDARD = "standard";
ChangeRequest.EMERGENCY = "emergency";
ChangeRequest.CHANGE_REQUEST = "change_request";
ChangeRequest.INFRASTRUCTURE_SERVER = "infrastructure_server";
ChangeRequest.prototype = Object.extendsObject(ChangeRequestSNC, {
type: "ChangeRequest"
});
ChangeRequest.newInfrastructure_Server = function() {
return ChangeRequestSNC.newChange(ChangeRequest.INFRASTRUCTURE_SERVER);
};
ChangeRequest.newNormal = ChangeRequestSNC.newNormal;
ChangeRequest.newStandard = ChangeRequestSNC.newStandard;
ChangeRequest.newEmergency = ChangeRequestSNC.newEmergency;
ChangeRequest.newChange = ChangeRequestSNC.newChange;
- 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
‎10-26-2016 06:03 AM
Hi Aditya
Your answer about that the script include "ChangeRequest" extends from "ChangeRequestSNC" was 100% correct!
I was using capital-letters and not small letters.
It should we written in the same way as in the script include "ChangeRequestStateHandler".
ChangeRequestStateHandler.prototype = Object.extendsObject(ChangeRequestStateHandlerSNC, {
INFRASTRUCTURE_SERVER:"infrastructure_server",
Thanks
Soeren!