I have a list (call it List A) with a workflow that runs when a new item has been created.
As part of the workflow, an approver will be assigned a task which will in turn update items in another list (List B)... so far so good.
Users are able to create multiple items in List A, that can update the same item in List B. So when an approver were to approve all tasks related to a specific item in List B, it may have conflicts and incorrect data. (The data field keeps a count).
Real life example is this:
- John Doe submits three vacation requests, each request is for 3 days, 5 days, and 7 days of vacation to be taken.
- John Doe's manager is assigned the task to approve the three requests, and in turn, the manager approves all three requests back to back within a minute.
- the approved request will run a workflow that will update John Doe's Leave Profile, which contains a count to see how many vacation days he has taken based on all approved requests.
I am finding that the values being counted in the Profile is not getting and setting the correct numbers, due to conflicts of when each task will run and update the workflow. The first request will update the profile, but the 2nd request will update at the same time, and thus not capturing the first request.
1. In the Profile, the count for number of total vacation days taken is initially 0
2. Request #1 is for 3 days, and will update the Profile to 3.
3. Request #2 is for 5 days, but instead of updating the profile AFTER Request #1 has done updating it, Request #2 will update the profile to 5 - which is obviously wrong since it should be 8.
The potential solution I am thinking is to have in the workflow to check out the Profile as soon as one of the request starts to update it. So do so, I need to check if that Profile item has been "checked-out", if it is, then it needs to wait until it's checked back in.
Is this something that can be done in Nintex Workflow for Office 365?
Try using the Query List or Office 365 Query List action to retrieve the item and return the "Checked Out To" column value. Alternatively you could use the same query list action but make "Checked Out To" a search filter. If it returns zero results, you know it's been previously checked out. Then you'd need to loop until is isn't checked out any more.
My list is a Custom List and does not have CheckIn/CheckOut capabilities (that feature is only for Document Libraries).
Even if I were to create my own CheckIn/CheckOut, I will still encounter the same problem where two workflows can potentially edit the same item at the same time.
Could you add a "flag" column (maybe a Yes/No checkbox) in your List B profile that is turned "on" when a workflow is updating it and then "off" when that workflow is done?
Then in or List A workflow, you query to see if the value of "flag". If it's "on" then pause for duration, then loop back to check the "flag" again and proceed when "flag" is "off".
Essentially the same thing as the embedded checkin/out but you're using a custom "flag" column rather than the check-in/out value.
That wouldn't work either, since that is no different than the CheckIn/CheckOut column.
The issue is that when two workflow instances both try to access the "flag" and both sees that it's not set, bothe Workflow will set it and continue to process what it needs to do.