Create Expedite change from Incident

Hareesha
Tera Contributor

How to create Expedite Change from Incident.Expedite change is like Normal change.

1 ACCEPTED SOLUTION

Mark Manders
Mega Patron

It looks like you are setting your Change Request as a normal one (var changeRequest = ChangeRequest.newNormal()). Your setting of the type value isn't over writing that. Put this in as your script (make sure you also have a Change Model for Expedite):

var changeRequest = new GlideRecord('change_request');
changeRequest.initialize();
changeRequest.setValue("type", 'expedite'); // or the value you have given it
changeRequest.setValue("chg_model", 'sys_id_of_expedite_change_model');
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.rfc = sysId;
current.update();

Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

View solution in original post

7 REPLIES 7

Can you share your code? Is the 'expedited' a choice on the change type field, so it can be set and did you set it in your code?


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Yes i have set the value,choice value is expedited
 
(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('type','expedited');
    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.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 Manders
Mega Patron

It looks like you are setting your Change Request as a normal one (var changeRequest = ChangeRequest.newNormal()). Your setting of the type value isn't over writing that. Put this in as your script (make sure you also have a Change Model for Expedite):

var changeRequest = new GlideRecord('change_request');
changeRequest.initialize();
changeRequest.setValue("type", 'expedite'); // or the value you have given it
changeRequest.setValue("chg_model", 'sys_id_of_expedite_change_model');
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.rfc = sysId;
current.update();

Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark