Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

how to modify "Create Emergency Change" UI action to only be visible on P1/P2 incidents

davematz
Giga Expert

I am working on the ITSM simulator for Madrid version in the Now Learning portal and am having a problem solving this.

I have gone to the "Create Emergency Change" UI action for the Incident (incident) table, but cannot figure out how to get the correct solution.  I have tried a number of different things, but none have been validated in my simulator.

I would appreciate the exact answer that I should have with steps explaining your solution so I can learn from this instead of getting frustrated because I don't understand.  Thank you.

1 ACCEPTED SOLUTION

It should be: && (current.priority == 1 || current.priority == 2)

add that to the original statement. If priority is 1 or 2 this will evaluate to true.

View solution in original post

14 REPLIES 14

adding more context

 

find_real_file.png

thank you works perfectly

thanks, please mark as helpful.

Bill

Rado Ehlenov
Tera Contributor

Hey guys, anyone could paste the script in a context for non-devs 😞 

(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.newEmergency();
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.setValue('state',4);
current.update();

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

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

 

Thanks!

Baby Lon
Tera Contributor

Ahhh...thats the reason. I had as condition "current.priority<=2..."
It has the same effect but if the simulator only checks for "current.priority == 1 || current.priority == 2..." 😉 Sure.
Thanks a lot.