Create Standard Change UI Action

sgmartin
Kilo Guru

Trying to modify the OOB UI Action to Create Standard Change.  The OOB UI Action has only 1 line and that is:

action.setRedirectURL(new StdChangeUtils().getURLForTask(current, 'rfc'));

I have looked at the script include StdChangeUtilsSNC and read that you can override the functions in there, but I don't think that's really what I need to do.  That one line redirects me properly to where I would select the type of Std Change I want.  However, what I would like to do is make some changes to the record that I'm currently on prior to being shipped off to the selection.  For example, set the state to Pending and also write a Work Note that a Std Change was created.

The problem is, any other line that I put in this script blows it up.

So if I do this:


current.state = -5; // Pending
current.u_pending_reason = "Pending Change Request";

current.work_notes = "Standard Change  created";
var mySysID = current.update();

action.setRedirectURL(new StdChangeUtils().getURLForTask(current, 'rfc'));

It goes no where.  I can't even get gs.log statements to work.

Any ideas?

1 ACCEPTED SOLUTION

Willem
Giga Sage
Giga Sage

As a workaround, can you try this:

var grIncident = new GlideRecord('incident');
if (grIncident.get(current.sys_id)) {
    grIncident.work_notes = "Standard Change  created";
    grIncident.state = -5;
    grIncident.u_pending_reason = "Pending Change Request";
    grIncident.update();
}

action.setRedirectURL(new StdChangeUtils().getURLForTask(current, 'rfc'));

View solution in original post

3 REPLIES 3

Willem
Giga Sage
Giga Sage

As a workaround, can you try this:

var grIncident = new GlideRecord('incident');
if (grIncident.get(current.sys_id)) {
    grIncident.work_notes = "Standard Change  created";
    grIncident.state = -5;
    grIncident.u_pending_reason = "Pending Change Request";
    grIncident.update();
}

action.setRedirectURL(new StdChangeUtils().getURLForTask(current, 'rfc'));

Works great.  Thx for the quick response.

jaspreetk
Tera Contributor

what if I want set parent field on standard change request with the sys_id of the task it is created from. for example, if i want to create standard change from INC12345, parent field on change should have display value INC12345.?