This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Collect information about all assignments

Hi M-Files community,

I am currently working on an use case where users may select multiple approvers for each workflow step. Those users get assignments and can approve or reject it. If all approve, we got to next workflow step. The same approach in next workflow step. 

Generally, this approach works but I see now that I will have a trouble with approval dates and comments. I have a requirement to show all approval dates and comments on the metadata card.

User can provide comment during approval/rejection and I would like to re-use and as well as date/time when approved.

One idea would be to have a comment metadata for each step of workflow that is filled with date/time + name of approver + comment each shown in a new line (I could have 10 approvers in workflow step, so would have 10 comments and approval dates). I would need to react on approve/reject event (not quite sure which one or if I can get information when someone approve/reject assignment) and update that metadata accordingly.

Sounds somehow quite overwhelming. 

Wondering if you have better idea and concept to solve this use case. One problem I find with assignments is that the completed ones are not shown afterwards. I assume they could be searched for specific document but still.

Hope you have some good ideas.

Thank you.

Dejan

Parents
  • Hi Dejan,

    We do almost exactly what you are describing at a customer of ours. An event handler on the assignments updates the object/document it is linked to, and adds their name, the date, the action (approve/reject) and the comment to a multi-line text field. In our case, we hide the property on the metadata card, but it is written out in the document itself.

    I am curious if someone has an alternative solution.

    Vicky

  • Hi Vicky,

    Thanks for response. So I am on the good track.

    Which event do you use to get update of an Assignment object? As mentioned, I would need to catch every approval and take date time and comment. I have searched for specific event but could not find it. Or do I need to listen on generic BeforeChange event and check if Object changed was Assignment?

    Do you use than history method on assignment object to get last modified date and comment or is there a better way?

    If you can share a bit more detail, it would be really great.

    Thanks.

    Dejan

  • Hi Dejan,

    I wrote my code in a custom Vault Application. You could accomplish the same thing in VBScript I suppose, but it will require more work.

    You can use the AfterCheckInChangesFinalize event because you are not modifying the assignment object. You can either filter on the Assignment Object Type, or on the specific class if you have one (see https://developer.m-files.com/Frameworks/Vault-Application-Framework/Attributes/Event-Handlers/#filtering-by-class-or-object-type)

    You can tell if the assignment has been approved or rejected by checking if the built-in property RejectedBy or CompletedBy have the current user as a value .

    The Comment can be found in the VersionComment.

    For the Date you can use the LastModified property.

    You can get the Object the assignment is linking to, by calling GetDirectReference(PropertyDefinition). Make sure you can modify the object and use StartRequiredCheckOut, append the new comment to the existing value, save properties and EndRequiredCheckOut.

    And you're done!

    Good luck,
    Vicky

  • Thanks Vicky. That will work definitely. The only potential problem is if users start writing long comments. As I have multiple approvers, I could easily come to the limit of multi-line property (I think 2000 characters). I miss a multi-select list of texts or multi-line texts, this would help to be sure this kind of cases work. Also I miss the list of assignments linked to the document that I could easily reference in code. It looks like only latest assignment is provided.

    I used AfterSetProperty event on Approval Assignment, I check additionally document class so that I don't take Approval Assignment from other classes. Other than that I followed your steps and it works.

    Thanks again!

Reply
  • Thanks Vicky. That will work definitely. The only potential problem is if users start writing long comments. As I have multiple approvers, I could easily come to the limit of multi-line property (I think 2000 characters). I miss a multi-select list of texts or multi-line texts, this would help to be sure this kind of cases work. Also I miss the list of assignments linked to the document that I could easily reference in code. It looks like only latest assignment is provided.

    I used AfterSetProperty event on Approval Assignment, I check additionally document class so that I don't take Approval Assignment from other classes. Other than that I followed your steps and it works.

    Thanks again!

Children