The User Case is the approval of “products” to organization managers based on a Product property (organization). This means Product A could require 2 approvers if it’s assigned to 2 organizations, while Product B could only require 1 approval. Product organizations do not require to be unique between each others.
A requirement has been added to set up approval tasks for a dynamic number of users (managers) who each need to approve for one or more “products” based on some List Item’s field.
There are several conditions:
Since managers are not likely to use SharePoint, the approval/rejection needs to be handled from an email. I have this already covered by including a link on an email/task-notification to a View on my Angular App (which can be a custom ASPX) that runs a JS script to Approve/Reject based on querystring parameters and logged in user. This solutions is already approved by user, no changes needed, just putting this for context.
The workflow must not advance to next logical stage until all managers Approve their tasks.
If a manager Rejects their task, the workflow will go to a “Revision Stage” in which the Initiator will review the item’s data. Since the Rejection happens automatically from the email, it’s responsibility of the Initiator to contact the manager via phone/message/email and get the details
Now, the REAL PROBLEM. When Initiator reviews the information, it may result in:
a) The number of “products” assigned to any manager might change. Think of this as reassigning the products from one manager to another. This needs to trigger new approval tasks for each affected manager.
b) A manager might reject all their products, but they need to be reassigned to an existent or a new Manager.
c) Only if a manager is affected by any of these changes, they need to get a new approval task, otherwise, their given response (if any) remains untouched.
Because it’s SharePoint Online, I don’t have access to any Server-Side development including Timer Jobs and Event Receivers and the only tools I have available are Designer, REST API and CSOM within an AngularJS App.
First, I don’t know how to create the tasks (if needed) for each manager. With a Task Process I cannot catch each individual response and, if I try looping through managers to create task, I cannot do it either because the number is dynamic. Also, I would still need to either Wait for Response on all tasks or Wait for a field in the item to change, but this brings up the next problem described below.
Second, I cannot figure how to handle the “if one rejects, then review information but keep existing tasks alive”. I was thinking of, instead of creating tasks, just manage a field in list items marking them as “Completed” or not; but with this approach I’m concerned for concurrency. Like what would happen if one manager rejects and, while Initiatior is making changes, then another one rejects as well.
If this was On-Prem, I wouldn’t have gone for a Workflow, but for a pseudo-workflow using Event-Receivers, SharePoint Lists and Timer Jobs. I would’ve implemented this with an Item Receiver to watch for changes in the assignment of products to managers and check the status of these assignment for completion in order to send emails. The main workflow would just exist in another list checking a “Status” field in order to simulate the Workflow Stages.
P.S. I would be open to “this is not possible” answer but, I’m looking for suggestions of anything I haven’t tried yet.
Thanks in advance