The Now Platform® Washington DC release is live. Watch now!
‎04-08-2020 08:13 AM
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;
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:
Solved! Go to Solution.
‎04-08-2020 02:55 PM
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
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.
‎04-08-2020 08:25 AM
Why not display the field on the RITM form?
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();
‎04-08-2020 09:03 AM
Hi Brad,
The idea behind adding the stage as a variable is so that it shows up in the approval form as shown below:
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?
‎04-08-2020 10:27 AM
Yeah, a variable is probably the best way to go in that case. did .getDisplayValue() work for you?
‎04-08-2020 11:20 AM
It does! in a way.. I hope you don't mind if I ask for more help.
So, I was planning to hide the variable, but for testing purposes, I left it visible. Anyway, upon testing, it's not showing the current stage, but actually the next:
And here's the script to set the RITM:
So I'm not sure why it's looking at the next stage that has not happened yet.