- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 03:23 AM
Hi,
I am trying to increment an integer field on the sc_req_item table. The idea is in a flow a 'For each' loop will call a sub-flow which has an update record action. The update record will +1 to the integer field, then at the very end of the sub-flow it will -1 from the field.
The reason for this is because we want users to be able to submit a request where they can select either 1-11 items. each of these items create a task. We also want all tasks to be created at the same time so we have un-checked the 'wait for completeion' on the sub-flow that runs inside the 'For each'. The main flow will then look at this integer field and will know to complete out the requested item once the interger field hits 0 (the original value).
To update the field I am using the script function in the flow action.
var count = fd_data.subflow_inputs.requested_item.u_parallel_process_count;
count++;
return count;
The issue I am getting is the field when being triggered by its related catalog item will only go up by 1.
After doing some quick testing I found that when I run the 'Test' function in flow designer this successfully inrements and decrements. For some reason when it is triggered via the catalog item it only updates to 1 no higher.
Am I missing something in the code I am using. I am about to start using gs.warn and check the logs to see what I am getting after I declare the variable, and after teh return count++.
TO NOTE: the -1 in the subflow does not run intil the task is closed, so this is not the case of the system immediately +1 and then -1.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 09:04 AM
Just did a quick test with wait for duration. Looks like doing a small wait for condition right after the sub-flow action got it working. Odd that there is some difference in speed for it to work on the Test function but fails for catalog item trigger.
Thanks for taking the time to look!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 06:49 AM
@Jacob23 I think in that case you need to pass count as output and pass it to flow.
And then from flow you need to bring it as input in next run so that it does not get reset everytime.
There is something which is triggering var count = fd_data.subflow_inputs.requested_item.u_parallel_process_count; to set to 0 everytime
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 09:04 AM
Just did a quick test with wait for duration. Looks like doing a small wait for condition right after the sub-flow action got it working. Odd that there is some difference in speed for it to work on the Test function but fails for catalog item trigger.
Thanks for taking the time to look!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 09:06 AM - edited 12-13-2022 09:18 AM
Glad!! New learning.
Mark the relevant answer correct so that it can help others.