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

Using assignments and workflows to create a task with subtasks

I want to create a task or object representing an activity, "Source code review" (SCR), with several linked subtasks ("review step" tasks) which must all be completed to mark the task as completed. The subtasks should only be assigned to/be able to be completed by the person who has been assigned the main task.

The way I've approached this is to create a new object type, "validation task" and two classes, "source code review" for the main task type, and "source code review step" for the sub-task/step. I've added "Reviewer" (the person who should perform the SCR task) as a required property of the SCR object. I've also created two workflows, "source code review workflow" to use with the main SCR object, and a "Pass/Fail"

However, I can't see any way to make the workflow state transition for the main object dependent on the workflow state of the linked objects. Is this possible without scripting?

I've attached an export package with the metadata objects/classes, in case my explanation is not precise enough. It can be summarized as follows:

Object type: Validation task

Class: Source code review
Required property: "Included source code review steps" (multi-select from list of objects with class "source code review step")
Workflow: "Source code review workflow" (SCR Pending (object is automatically assigned to user specified in "reviewer" metadata) -> SCR complete (PASS) or SCR complete (FAIL) )

(The SCR workflow will be more complex in its finished state, so it can't be the same PASS/FAIL workflow used for the sub-steps)

Class: Source code review step
Required property: Acceptance criteria (free text description)
Workflow: PASS/FAIL (no state -> PASS, FAIL or "Not Applicable")
SCR metadata.zip
  • Would it not be enough to have a workflow on the primary object and create a number of separate Assignments in the same Workflow State - all assigned to the same person but with different assignment descriptions while using an assignment class that requires all separate assignments to be marked complete before the workflow can move on?
    If you need the subtasks to be completed in a certain order, then you could add a Workflow State for each of the steps and put the Assignments in the relevant States.
  • Thanks for the suggestion! I'm trying that now.

    I don't see how to require that all the assignments have been completed before allowing the state transion from "SCR pending to "SCR complete" for the primary object, though? (The state transition should not be automatic)

    Also, is there any way to set conditions that have to be fulfilled before an assignment is approved? For example, I'd like the assignment for each sub-task to be able to approved in two cases: if the requirement described in the assignment is fulfilled, or if it is not applicable. So I added a select-from-list property to the assignment class to describe this, but I can't see a way to require that a property value on the assignment metadata card has been defined before the assignment is approved/rejected...

  • It should be possible to create a script for Post Conditions that would search for all separate assignments related to the primary object and check whether they have been marked complete and if yes then AllowStateTransition = true
    You cannot put conditions directly on to the separate assignments. I suppose you could let the separate assignments run through their own simple workflow and put conditions into the workflow. I haven't tried that approach but right now I can't see anything that would prevent it. You should probably create a new Assignment Class for this purpose and force a workflow to run on all objects in that class.
  • Thanks for the advice. I've applied the "PASS/FAIL" workflow to the "SCR step" assignment class, but I don't know how to mark the assignment as complete as part of a state transition (and also how making sure the assignment can only be completed this way). I assume that requires scripting? There is the "actions" tab for each workflow state and a "set properties" option under that, but I couldn't find any property which describes if the assignment has been completed...


    Edit: I tried adding the following action script to the "PASS" state: "Vault.ObjectPropertyOperations.MarkAssignmentComplete ObjVer".

    I don't get any error messages but nothing appears to happen when making the state transition.
  • Would one of you scripting gurus please step in and guide jarlemag here?
  • Former Member
    Former Member
    When I read www.m-files.com/.../index.html

    It states: "Marks the assignment as completed by the logged-in user."

    When it's an automatic transition, the user is the M-Files Server, maybe the cause of doing nothing?

    The related MarkAssignmentCompleteByUser method states: "Marks the assignment as completed by the specified user."

    I never used these, but it's worth a shot.
  • Thanks for the advice, everyone. I don't quite get why seeing as the state transition is manual, not automatic, but the following code did the trick:

    [tt]Vault.ObjectPropertyOperations.MarkAssignmentCompleteByUser ObjVer, CurrentUserID[/tt]

    Edit: The green checkmark appears next to "assigned to:" on the metadata card that indicates that the user has completed the assignment, but the object icon for the assignment doesn't switch to the icon with a green checkmark on it. Any ideas why?
  • Dear jarlemag,


    Edit: The green checkmark appears next to "assigned to:" on the metadata card that indicates that the user has completed the assignment, but the object icon for the assignment doesn't switch to the icon with a green checkmark on it. Any ideas why?


    Did you get this resolved?
    I'm having same issue: when using M-Files API MarkAssignmentCompleteByUser in workflow action script. Assignment is showing green checkmark, but "Completed" property shows "No" and assignment icon does not have green checkmark
    Only after making any manual change on assignment metadatacard, Completed property changes to "Yes" and green checkmark appears on assignment icon

    MFiles version MFiles.2015.3 (11.3.4330.243) on Windows 10 (10.0.16299 Build 16299)

    Best Regrads,
    Tigu
  • A question for jarlemag and tigu:-

    Did either of you ever manage to find out/work out why the assignment icon didn't get a green tick when using setting "Assignment Completed By" in a script?
  • Sorry, I haven't worked more on this. Would still like to get it working...