Configure state choice list and behaviour

gianluca5
Giga Contributor

ITSM Simulator: HELP!!

 

We would like state values to be updated to allow the service desk to have more information on what the next step in the process is.

 

1. Disable the State choice: "On Hold". (again, do not delete it)

 

2. Add a new State choice with the Label of : "Awaiting Change", in the sys_choice record make the Value field: 4.

 

3. Set the incident state to "Awaiting Change" when a Change is created from an incident, by updating the existing "Create Normal Change" and "Create Emergency Change" UI actions.

 

Use 'state' not 'incident_state'

10 REPLIES 10

(function(current, previous, gs, action) {
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("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);
changeRequest.insert();

action.setReturnURL(current);
action.setRedirectURL(changeRequest.getGlideRecord());

})(current, previous, gs, action);

 

WHERE????

(function(current, previous, gs, action) {
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("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);
changeRequest.insert();

current.state = 4;

action.setReturnURL(current);
action.setRedirectURL(changeRequest.getGlideRecord());

})(current, previous, gs, action);

LTFg6
Tera Contributor

Hi gianluca5,

 

paste the script that Alberto Consonn  provide in 

current.state = 4;

 changeRequest.setValue("short_description", current.short_description);

changeRequest.setValue("here");
changeRequest.setValue("description", current.description);
changeRequest.setValue("cmdb_ci", current.cmdb_ci);

Why we need to add current.state = 4; in script ??

Great shortcut, thank you!