Flow stages are not working after using Do the following action in Flow designer

Prajwal G Vaish
Giga Guru

Hello team,
Have created a flow designer which is used to create 2 tasks simultaneously using do the following in parallel 
let say if one task is closed incomplete then it should not wait for other task rather than it should update the other task to closed incomplete and update the RITM to request cancelled using OOTB flow stage.

when we add Flow stage once updating the related Tasks, then updating the RITM using the OOTB add stage icon to add a stage to RITM which is not working.

Could anyone please let me know how can we achieve this using OOTB Stage.
"Should create 2 tasks simultaneously if one of the task is closed incomplete then other task should also be updated to closed incomplete and respective RITM should also be updated to stage Request cancelled [using OOTB]and State Closed incomplete.

Thank you
Prajwal

10 REPLIES 10

Mark Manders
Mega Patron

You can set the stage in your flow. After the tasks are closed incomplete, just set the stage on requested item to closed incomplete.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

OlaN
Giga Sage
Giga Sage

Hi,

You cannot add stages in the parallel execution of the tasks, those two executions might interfere with each-other.

Instead, set one stage before going into the creation of the two tasks, then after the tasks are complete/incomplete, set the stage again accordingly.

  1. Adding the OOTB Flow Stage:

    • The issue you're encountering is that when you add a flow stage to update the related tasks, the OOTB "Add Stage" icon for adding a stage to the RITM is not working as expected.

    • Solution: To overcome this, you can use a Run Script action within the flow stage that updates the related tasks. Within this script, you can leverage the current object to access the RITM and use the GlideRecord API to update its stage and state.

    Here's a simplified example of how the script might look:

    JavaScript
    (function executeScript() {
        var gr = new GlideRecord('sc_task');
        gr.addQuery('related_item', current.sys_id);
        gr.query();
    
        while (gr.next()) {
            gr.state = 'closed incomplete';
            gr.update();
        }
    
        // Update RITM stage and state using GlideRecord
        var ritmGr = new GlideRecord('sc_item');
        ritmGr.addQuery('sys_id', current.sys_id);
        ritmGr.query();
    
        if (ritmGr.next()) {
            ritmGr.stage = 'Request Cancelled';
            ritmGr.state = 'Closed Incomplete';
            ritmGr.update();
        }
    })(current);
    Use code with caution.
     

    Remember to replace 'sc_task' and 'sc_item' with the actual table names of your tasks and RITM records, respectively.

  2. Handling Parallel Task Completion:

    • To ensure that both tasks are updated correctly even if one finishes before the other, you can use the Wait for Completion action after the "Do the following in parallel" action. This will pause the flow until both tasks have completed.

Complete Flow Design:

  1. Create two parallel branches within the "Do the following in parallel" action, each containing an action to create one of the tasks.
  2. After the parallel branches, add a "Wait for Completion" action.
  3. Add a flow stage with a "Run Script" action to update the related tasks and RITM as described above.

You realize that in a flow you don't have to script this, but you can just do a lookup? I know that's not an answer chatgpt will give you, so that's why I mention it.

Did you test this, before copy/pasting it?


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark