UI Action condition/script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2018 06:37 AM
Hi All,
On our incident table we have a UI action 'Create Emergency Change' - this will create a new change record copying over the relevant records. On our change_request we have the field 'u_change_source'. We only allow you to create an emergency change when the incident is a sev1 or sev 2. If it is not one of these severities the UI action does not appear.
When the emergency change is create from a sev 1 incident it adds 'inc_sev1' to the u_change_source field. If it is from a sev 2 incident it adds 'inc_sev2'.
On problem we only allow the 'create emergency change' ui action on sev 1 problems and this populates u_change_source with 'prob_sev1'.
The change source field is then used to drive which path of the workflow is followed.
On the change request form we have the ui action 'convert to emergency change'. This allows a normal change to be converted to emergency change and cancels the normal change workflow and starts the emergency change workflow. Again this should only be allowed if there is a sev1 or 2 incident or sev 1 problem linked to the change request.
Currently there is no checks on the UI action if an incident or problem is linked and the severity of these logs. Due to this it can mean people use the convert to emergency UI action and the workflow becomes stuck as nothing is setting the u_change_source field.
I need to amend the UI action so that it either only appears when a sev 1 or 2 incident or sev 1 problem is linked.
When either a sev1, sev2 incident or sev1 problem is linked I need it to populate the u_change_source field as above.
Any help on how best to achieve this will be greatly appreciated.
Thanks
Sam
Convert to Emergency UI Action
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2018 07:10 AM
Hi Sam,
You could populate the u_change_source field when a record is linked with the change, you would need a business rule on the incident and problem table that would run when the 'rfc' field changes (assuming your using the OOB change request reference field). Script would be something like below for incident:
var gr = new GlideRecord('change_request');
if(gr.get(current.rfc)){
if(current.severity == 1){
gr.u_change_source == 'inc_sev1';
gr.update();
if(current,severity == 2){
gr.u_change_source == 'inc_sev2';
gr.update();
}
Do a similar one for problem and then your UI action can be restricted based on the u_change_source field the same way as normal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2018 07:42 AM
You should be able to add the following to the end of the condition (depends on how many characters you have left):
&& (["inc_sev1", "inc_sev2", "prob_sev1"].indexOf(current.u_change_source) > -1)
This checks to see if the value of "current.u_change_source" is in the array of string values.