Show workflow stage as a variable in RITM form

Marc_See
Giga Contributor

I'd like to show the stages of a requested item on the RITM. Since I only want this to only show for this particular catalog item, I created a variable "item_stage". Whenever the stage changes, I want the RITM variable to be updated. What I tried to do is that every time the SCTASK is created, I run this script:

current.variables.item_stage = current.stage;

find_real_file.png

I'm not sure if this is the best approach or the right syntax. I can't get this to work because the field is just blank:

find_real_file.png

1 ACCEPTED SOLUTION

Wait, I've had an epiphany.  Scrap all that and create an after update business rule on sc_req_item with the Filter Condition Stage changes

find_real_file.png

You can also add certain Items to the Filter Conditions, but if this variable is not found it just won't do anything - no errors displayed, or erratic behavior.  Add this Script in the Advanced tab

(function executeRule(current, previous /*null when async*/) {

current.variables.item_stage = current.stage.getDisplayValue();
current.update();

})(current, previous);

Now the variable will be updated every time the RITM stage changes.  The workflow I'm testing with starts with a run script to set some RITM values, then an approval, a task, then another approval.  I noticed when I submitted the request the RITM stage showed Approval as it was awaiting the first approval, but the variable was empty.  This is a timing issue that I've seen before on RITM creation, so adding a 10 second Timer activity prior to the approval did the trick.

View solution in original post

14 REPLIES 14

Brad Bowman
Kilo Patron
Kilo Patron

Why not display the field on the RITM form?

find_real_file.png

You could add a UI Policy or Client Script (not catalog) on sc_req_item if you want to hide the field based on cat_item.

If you really want to populate a variable, this will work in your workflow script

current.variables.item_stage = current.stage.getDisplayValue();

 

I like this idea, Brad.  How did you get the workflow chevrons to appear at the top of the RITM?  I'm not actually sure what they are called.  Are they an option when selecting a variable type?

 

Thank you!

You can find that in Process Flow in the left nav.  On the sc_req_item table you would create a record for each chevron that you want to appear, giving it conditions for when that one will be active, then if it's not already there, add Process Flow to the form via Form Layout / Designer...

Marc_See
Giga Contributor

Hi Brad,

The idea behind adding the stage as a variable is so that it shows up in the approval form as shown below:

find_real_file.png

There's multiple approval tasks in the workflow (1 in the beginning and 1 close to the end). The approver wants to know what he's approving. So we figured we can show the stage of the workflow to show the stage of fulfillment.

Since we can't really do anything on the approval form to show the RITM stage, we figured this is the next best thing we can do.

What do you think?