- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2020 12:56 PM
With that in mind, I set the Stage on the 2 run scripts before the task. So for the stage "Request Review", there's 2 RS and 1 Task (lol!):
The Stage variable updated just fine, but... Once the task was closed, the stage variable did not update to the next stage, even though there's a RS before the approval task.
Also, the script is only in the "Set var stage value" RS's, not on anything else.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2020 01:42 PM
The Stage has to be set prior to your run script. The second time you run this, after the task, it must not be changing the RITM stage until after the script runs.
To you hope to use this dynamically in other scenarios? It seems like you could just set current.variables.item_stage = 'Waiting for Product Manager Approval' before that approval since you know that's the stage it will be in during that approval, and just do the same before any other approvals.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2020 02:06 PM
I was seeing if I can avoid using a direct approach and wanted this to be more dynamic, but this works as a work around.
Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2020 09:02 AM
Worked like a charm! I can't believe you had an epiphany during the Easter break. lol!
You the man!