
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2017 08:20 AM
Hello,
I am struggling to find a solution to a problem with updating a Catalog Task and sending the update over to the parent Requested Item. In my Requested Item workflow, I wait for when certain variables update in order to move the workflow forward. What is happening is that I am creating a Catalog Task with the same variables and when the service provider updates the Catalog Task variable, it will not trigger my workflow. In my workflow I have in a Wait for Condition activity:
if(current.variables.av_event_description.changes() ||
current.variables.location_details.changes() ||
current.variables.av_event_support_desc.changes()){
//Do Something
}
What is strange is when I update the Catalog Task variables, it will reflect the change in the Requested Item's variables but does not count as an update. This ultimately doesn't move my workflow forward. What I have tried is to create an onAfter business rule, on the sc_task table, with an order of 2000 to check when the variables change. This was to update the RITM's variables and then do a .update(), but this also brought me no luck.
onAfter Business Rule:
(function executeRule(current, previous /*null when async*/ ) {
var vars = current.variables;
var task_var_arr = [];
for (var key in vars) {
if (vars[key] != "") {
if (vars.changes()) {
//gs.addInfoMessage(key + " CHANGED -> " + vars[key]);
task_var_arr.push({
id: key,
value: vars[key].toString()
});
}
}
}
//Update RITM variables with associated Catalog Task variable values
var par_ritm = new GlideRecord("sc_req_item");
par_ritm.addQuery("sys_id", current.parent);
par_ritm.query();
if (par_ritm.next()) {
for (var j = 0; j < task_var_arr.length; j++) {
par_ritm.variables[task_var_arr[j].id] = task_var_arr[j].value;
}
par_ritm.update();
}
})(current, previous);
The end result that I trying for is when the specific Catalog Task variables change, this moves the parent requested item's workflow forward.
Any help on this would be much appreciated!
Thank you,
Justin
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2017 09:21 AM
I have found a solution to my problem, it may not be the best but it works! I have a business rule that monitors for any updates to the variables on the sc_task table. Once it finds a valid update, it will send an update to the workflow activity forcing the code to run within the activity. I was able to get passed that initial roadblock based on R0b0's advice. The next part is in the workflow activity. My wait for condition calls a script include that monitors the sys_audit table for any changes to the specific catalog item. Once the script finds a valid update, it will then proceed through my workflow. Between 3 scripts and scratchpad variables, I have found a solution.
If you have any questions about the code or any particular questions, please let me know.
Thanks,
Justin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2017 08:27 AM
Hi Justin
The workflow will move on only if you change the status of your task.
The system won't send any update to the workflow if you change the variables.
if you want to understand the method used OOB. Have a look to the business rule named 'SNC - Run parent workflows'
Maybe you can create something similar to this one but triggered by the update of your variable without touching the OOB one.
Cheers
R0b0

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2017 09:21 AM
I have found a solution to my problem, it may not be the best but it works! I have a business rule that monitors for any updates to the variables on the sc_task table. Once it finds a valid update, it will send an update to the workflow activity forcing the code to run within the activity. I was able to get passed that initial roadblock based on R0b0's advice. The next part is in the workflow activity. My wait for condition calls a script include that monitors the sys_audit table for any changes to the specific catalog item. Once the script finds a valid update, it will then proceed through my workflow. Between 3 scripts and scratchpad variables, I have found a solution.
If you have any questions about the code or any particular questions, please let me know.
Thanks,
Justin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2017 02:48 PM
Justin - would you be willing to share the code with me? This is an ongoing thing for me that I constantly have to work around.
Let me know -
Thanks,
Suzanne