Trigger two workflow on same table at same time

avani2
Giga Contributor

I have a main workflow that is running for a catalog item.

i have created another separate workflow "A" on req. item table which is getting triggered when that state changes to "Awaiting user info".

these two workflows are not linked and i can't create an activity in main workflow to evoke this "A" workflow.

But when this A workflow gets triggered, main workflow gets cancelled.

Is this because two workflows which are not called by each other and are on a same table can't run parallel ?

I want the main workflow to run again where it got stopped as soon as the state changes to "Active".

I have a button on the form which is visible only when the state is ""Awaiting user info"." and sets the state to active.

How to achieve this scenario.

6 REPLIES 6

rehani
Tera Contributor

Hi,



You can only have one main workflow which is the one that drives the different stages for the requested item.



It sounds like you want your main workflow to pause while another activity runs 'Awaiting user info'.   Is that correct?


I'd need more information around what activities are run un both workflows to give a more detailed response but you will likely need to have the second workflow as a sub-flow that can be triggered within the main workflow at various points depending on the state changing.   e.g. have it waiting for a workflow event before being triggered.   The state changing to 'Awaiting user info' could trigger this workflow event.


If the workflow moves past this point without the sate changing to 'awaiting user info' you just cancel that specific activity.



Regards,



Rehan


avani2
Giga Contributor

hi rehan,



i understand that mostly we create one main workflow and trigger sub flows from it only.


main workflow have approvals and task activities while the other workflow that i have created is only for state "awaiting user info" and has some activities.



but is there anyway we can have new workflow triggered as state changes and pause main workflow,   till the time state changes again to active.


rehani
Tera Contributor

Hi,



You cannot pause a workflow while you run a second one and then continue the first one.  


The only way ServiceNow handles something similar is running sub-flows.


What's the reason you require a workflow to be paused while you run the second one and not use sub-flows?


mayurkamble
Kilo Guru

Hi Avani,



As we know running two different workflow on the same table is highly ambiguous. Even though your workflows are not linked Catalog items, Req, and Req items are.


Now if you want one workflow to take a walk (pause) and to let another one to run, you need to link those two. And by linking I don't mean Subflows in utility, I mean 'Workflow' in Core Activities. You 'checkout' your main workflow, right click on the same go for 'Core Activity' select workflow, select your table in it, add your condition save it. This way you will have an independent workflow in the middle of your Main workflow as on of your Main workflow activities, which you can trigger on desired condition. That way your main workflow need not be in pause state while your other workflow runs because your main workflow is the one triggering the other one. The other workflow runs and passes over the control to the next activity in your Main Workflow.


This all works out fine, however there is one possible problem in this while validating, your Main Workflow might give you a Critical Error (Only One) now that depends on how the flow is associated. Otherwise it works just fine. I have Tried it.



If it doesn't just Glide Record the same table check for condition and assign the value to your desired field.


If you have to for Glide Record can you please mention the specific Requirement for which you needed to go for another workflow.


May be I can send you code for it.




Regards,


Mayur