I want to assign a subtask created on a transition to a project role

Mark Griffith May 8, 2017

I am using JMWE to create subtasks in a post function. I want to assign the subtask to a specific project role... How would I go about that? 

I have tried using findUsers Nunjucks annotations to access users but can't quite figure it out.

Any ideas would be much appreciated.

 

edit: using JMWE cloud FYI

1 answer

1 accepted

1 vote
Answer accepted
Russell Zera
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 10, 2017

Hi Mark! 

I have accomplished what you're looking for, it's a bit in-depth and complicated, but it DOES work. The way I implemented this was several steps. Let me know if you run into any issues with this process:

Step 1) Create a ghost status in your workflow. This status is one every subtask will pass through when created, but will automatically pass on to whatever your current first status is untouched unless other post-function is fired when doing the JMWE issue create. For the sake of this description I'll call it 'Draft'.

001.PNG

Step 2) Have a transition going from your 'To Do' status from your ghost status and call it 'Advance'. 

Step 3) Create a loop-back transition on your ghost status and call it 'Assign-Loop'. Create a post-function on that transition in JMWE for 'Assign to role member (JMWE add-on)' and enter 'Project Leads' role (insert your desired role in place of 'Project Leads' here). 

Step 4) In the diagram view of your workflow, click the transition line before your ghost status which is your 'create' transition. Open the post-functions and choose 'Transition Current Issue'. Use the 'Advance' transition you created in step 2, choose to delay the execution by 4 seconds, and (IMPORTANT) move that transition all the way to the bottom of the list of post-functions for that transition.

002.PNG

Step 5) Go to your original JMWE Post-Function where you call to create the subtask. For testing and example I did it on the 'In Progress' transition for this explanation. Here directly under your 'Create a new issue' JMWE you are going to add another post-function to 'Transition a linked issue'. Set it to link type 'is Parent of', and to run the transition 'Assign-Loop' that you created in Step 3 (above). Finally, delay this execution by 3 seconds. 

003.PNG

Step 6) Test what you did here. Remember that JMWE is run as an external command, so it will not immediately reflect the updates on your subtasks. Wait a couple seconds and refresh your screen and everything should be accurate. The assign-loop will assign to the FIRST member of the project role you select until you chose (alternatively you can select 'Assign to laste role member (JMWE add-on)' when creating the assign-loop post-function to get the LAST member of the project role you select).

(CLARIFICATION: The delays are selected so if an issue is created on that workflow in any other manner, it will automatically transition to the 'To-Do' status if not called on within that first few seconds, which the other post-function will call on when invoked. If you don't have it setup that way, it will assign ALL subtasks in the same status to the project role called even if you didn't want to do that. This allows you to pin-point only the post-function created subtask.)

Post on here if this works for you. Hope this helps!

 

Mark Griffith May 11, 2017

Thank you very much Russel for the response and effort you put into it. I have done this and can report that it is working as expected. As a side note: I needed to assign subtasks to multiple project role types such as Purchasing, planning, QA etc. I was able to achieve this by creating a new custom field and assigning the role type string at the time the new issue is created, the subtask could then conditionally execute the role assignments based on this field value attached to the issue. I am sure there are better ways to do it, but it is working very well for me. Once again, many thanks Russel.

Mark.

Russell Zera
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 11, 2017

Fantastic! Look forward to future run ins on the community!

Suggest an answer

Log in or Sign up to answer