VBScript - Wait for all assignees to respond before rejecting

Hi all,

With the OOB behaviour of approval assignments in M-Files, the assignment is marked as rejected as soon as one assignee rejects, without collecting a response from the others.

This is causing some issues with a new workflow I am creating. 

At the arrow going to 'Rejected', I have the below trigger.

The problem with this is that if there are multiple assignees for the approval, everyone else will miss it and not be able to review the document if someone rejects it straight away, as it will progress.

I do not wish to trigger the state transition as soon as someone rejects. I want to record a response from all assignees first, then mark as rejected if there is at least one assignee who marks as rejected, then trigger the transition once everyone has responded.

I believe that I may be able to script some logic to solve the above. For the logic I was thinking something like the below:

x = Total rejected responses to assignment

y = Total approved responses to assignment

z = Total number of assignees

If the sum of x + y = z (to check that all assignees have recorded a response)

And if x is equal to or greater than 1 (to make sure there is at least one reject)

Then trigger state transition.

I couldn't figure it out with the API documentation so I am unsure how to go about actually getting the values I need for the variables. I am also not a VBScript expert.

Sorry if I have described this in a really convoluted way.

Any help would be greatly appreciated.

  • Hi Luke, 

    I would highly recommend first to re-think if you really need this behavior as it will complicate your functionality and maintenance afterwards. 

    If you have a need, I would recommend to read through this forum entry, I have created some time ago about collecting information about assignments.

    In a nutshell, you would need to:

    • Wait until each assignment is approved/rejected (Event handler), and save info about that assignment (who approved/rejected and when, RejectedBy/CompletedBy and LastModifiedBy properties)
    • Save all these information (let's say into multi-line text box)
    • And then based on those information and your logic, move it to next workflow state or reject it. There you would need to use that 3rd option: "Trigger the state transition once the object ..." and implement your logic.

    The key is to implement event handler and catch all approvals/rejections on assignment object (would recommend "AfterCheckInChangesFinalize", VAF Event Handlers). I am not quite sure how the trigger "Trigger the state transition once the object ..." but I assume that it would be some form of  "Automatic State Transition Trigger" on which you would implement your logic. You would need to check in documentation if this trigger is actually automatic state transition trigger.

    The only part I am not completely sure is how you would get assignees on assignment object but I would guess you could search for that assignment object (based on some criteria) and get assignees from the object to do your logic.

    I would recommend to use VAF framework and not VB script as this could be overwhelming with scripting (but don't know your background).

    As you can see, there are quite a few bits to implement, it is definitely doable but I just wonder if you need to go that direction.

    Best,

    Dejan