How to prevent running a workflow while having the same workflow InProgress inside NERM?
- Example: pending Approval
I have external worker, there is a work assignment created for this worked and it is pending approval.
If I tried to create another request for the same profile while the first workflow is still InProgress, it will be created and I end up with 2 workflows with the same request.
Is their a way to detect active/pending workflows for the same worker profile, so I can prevent a new one from being opened?
I don’t think there is a built-in NERM workflow action that checks whether another workflow session is already in progress for the same profile.
There is a Duplicate Prevention action, but that checks selected attributes against existing profiles to detect duplicate profile creation. It does not check active or pending workflow requests, so it would not solve this use case.
One workaround you can try is an attribute-flag pattern. Basically, let the profile itself track whether a request is already in flight. You could add a profile attribute like requestInProgress. At the beginning of the workflow, add a Condition that checks that attribute. If it is already set, use a Notification to let the requester know why the request is being stopped, then follow with a Close Session action to close the duplicate session.
If it is not set, update the attribute to true using Set Attribute Values, then clear it back after approval, rejection, cancellation, or completion. It is not a native feature, but it is probably the closest workaround I can think of to prevent duplicate in-progress requests within NERM. It does add extra steps to every workflow you want to protect, and you need to make sure every exit path resets the flag properly so it does not get stuck.
Another design you could look at is to do this workflow outside of Nerm as a scheduled task. I have run into a number of items in the platform that has caused me to use this pattern.
I would use the API’s to pull in users via advanced search. I would then loop over them and calculate if a users status needed to updated. This method is very flexible as you can keep adding whatever complex logic you want to your process. The cons is that your going to have to rely on an external system from NERM to do the work.
Yeah, it has limitations with the attribute-flag approach. NERM doesn’t have a native “on cancel” trigger or callback that you can hook into to reset the attribute, so any time a requester cancels mid-flow or just closes the browser, the flag stays stuck.
Two options I would try as a workaround:
Cleanup with an Automated Workflow. Set up an Automated Workflow that runs daily, filters for profiles where requestInProgress is true, and resets the flag using Set Attribute Values. It’s not instant, but it prevents permanent lockout.
Switch to the REST API approach instead. Rather than maintaining a flag at all, use a REST API action at the start of the workflow to query GET /workflow_sessions filtered by the same profile and an active/pending status. If another active session exists, Notification + Close Session. If not, continue normally. This is stateless, so cancelled or abandoned sessions don’t leave anything stuck. No flag to manage, no cleanup needed.
I would lean toward option 2. It avoids the exact gaps you are running into.
Hi @Halim36 The best practice you can test in the QA/Sandbox environment to avoid such scenarios. In case of dupliates you can put conditions if there are multiple IP you need to consider in separete workflows. You can keep the workflow as disabled until you are not getting the expected results.