Mark stage field with red X

jbutz
Kilo Expert

I've seen the stage updated with a red X when the workflow for a Request Item is canceled. I would like to make that X appear under a certain error condition in my workflow. Does anyone know how I can accomplish that?

 

Below is a screenshot of what I am talking about.

failed stage.png

1 ACCEPTED SOLUTION

Ok, I figured out a really easy way to do it.



I have the conditions on a catalog task for 3 closed states (Closed Complete, Closed Incomplete, and Closed Skipped). The catalog task activity is set to the stage I want to show the rejected icon on if it fails. On the Incomplete and Skipped states I have it transition to a Run Script activity. The following is the code in the Run Script. It marks the previous activity as cancelled, which causes the red x to appear.



var gr = new GlideRecord('wf_history');
if( gr.get( activity.previous_activity ) )
{
          gr.state = 'cancelled';
          gr.result = 'cancelled';
          gr.update();
}

View solution in original post

8 REPLIES 8

justin_drysdale
Mega Guru

Check out the Script Include called, "WorkflowIconsStages".   It has the code that sets the icon.   However it may not work depending on how you use it.



Are you planning on using the red X somewhere else or are you planning on adding it to the Stage display (like in your screenshot)?



The actual Red X is called workflow_rejected.gifx.



https://YOURINSTANCE.service-now.com/images/workflow_rejected.gifx


Thanks for directing me to that Script Include, that is helping. The stage choices get a state associated with them at some point. Now I just have to figure out where that is held.


It appears whether or not something is skipped, completed, or rejected depends upon the Workflow Activity History.


Ok, I figured out a really easy way to do it.



I have the conditions on a catalog task for 3 closed states (Closed Complete, Closed Incomplete, and Closed Skipped). The catalog task activity is set to the stage I want to show the rejected icon on if it fails. On the Incomplete and Skipped states I have it transition to a Run Script activity. The following is the code in the Run Script. It marks the previous activity as cancelled, which causes the red x to appear.



var gr = new GlideRecord('wf_history');
if( gr.get( activity.previous_activity ) )
{
          gr.state = 'cancelled';
          gr.result = 'cancelled';
          gr.update();
}