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

VBScript to auto complete outstanding assignments under a document when it' done

Former Member
Former Member
Hi,

I am configuring/testing a new document workflow in M-Files: when a new document is created, a few separate assignments are created to trace the tasks user need to perform related to the document and send reminer email when due date is reached.

Here the my problem:
When the document reaches the final DONE state, all the assignments created earlier should be have been completed (the state transition is a proof that all the assignments are completed) . Instead of the user having to manual select each assignemnt and click: 'Mark Complete', I would like it to happen automatically. I belive the right way to implement this is: Workflow->(Done) State->Actions->"Run script". However I don't have enough VB expereince to code the script myself, or can I find a good example to begin with. I would appreciate very much if someone can share me some samples or give me a head start. Thank you in advance!

This is how my VB script should look like:
[list type=decimal]
  • Retrieve the list of assignments assigned to the current document;

  • For each assignment, if it is not completed, mark it as completed.

[/list]
Parents
  • Former Member
    Former Member
    Dear Tigu,

    Thank you so much for your reply. I tried the script you posted, and it actually works just fine.

    Regarding the problem you mentioned:
    "It does not work on Assignment that were created by "Create Separate Assignments" feature of workflow.
    It does seem to remove, whatever is selected in "Assigned To" property on assignment."


    There is a workaround after contacting M-Files support:
    Workaround:
    you can prevent M-Files from clearing out the "Assigned to" property from workflow assignments by adding the following script to the state that creates the assignment (select Run Script in the state's Actions tab):
    Vault.ObjectPropertyOperations.RemoveProperty ObjVer, 79 

    That line removes the linking between the workflow and the assignment, so M-Files will no longer make changes to the assignment based on what is happening in the workflow. The assignment will then remain assigned to the correct user when the workflow moves forward.
Reply
  • Former Member
    Former Member
    Dear Tigu,

    Thank you so much for your reply. I tried the script you posted, and it actually works just fine.

    Regarding the problem you mentioned:
    "It does not work on Assignment that were created by "Create Separate Assignments" feature of workflow.
    It does seem to remove, whatever is selected in "Assigned To" property on assignment."


    There is a workaround after contacting M-Files support:
    Workaround:
    you can prevent M-Files from clearing out the "Assigned to" property from workflow assignments by adding the following script to the state that creates the assignment (select Run Script in the state's Actions tab):
    Vault.ObjectPropertyOperations.RemoveProperty ObjVer, 79 

    That line removes the linking between the workflow and the assignment, so M-Files will no longer make changes to the assignment based on what is happening in the workflow. The assignment will then remain assigned to the correct user when the workflow moves forward.
Children
No Data