Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Setting assignee of sub-task based on custom single user-pick field value in post-function

Max Andersen September 18, 2017

Hi All,

Thanks for any help you can give.

I am creating several sub-tasks using JMWE post-functions and in the same instance trying to set the assignee of those sub tasks. I am trying to set them to the value of a custom field called Brand Manager which is set previously by the user.

I fear that I am not getting the syntax of the nunjucks expression correct - I have tried:

{{issue.fields.BrandManager.name}}

{{issue.fields.BrandManager.value}}

{{issue.fields.BrandManager}}

{{issue.fields.Brand_Manager.name}}

{{issue.fields.Brand_Manager.value}}

{{issue.fields.Brand_Manager}}

{{issue.fields.BrandManager}}

{{issue.fields.Brand_Manager}}

 

See the image below and the attempt to assign the Assignee.

 

2017-09-18_22-28-30.jpg

 

We sadly do not have Scriptrunner at our disposal.

 

 

1 answer

1 accepted

0 votes
Answer accepted
Max Andersen September 25, 2017

So for anyone interested - I found my solution the correct code was:

 {{issue.fields.customfield_10901.key}}

The custom field variable and number I found by testing the nunjuck template on an issue with {{ issue.fields | dump(2) }} which gave me a full list of all fields and their content - then it was simply a case of searching for what I knew was the field value

BTW All of this is done in the JMWE - Post-function - create sub-task screen - then simply in the Assignee field using the above code.

Only possible recently because of the new straight foward nunjuck template test capabilities in the above screen when entering the code - huge help!

David Fischer
Community Champion
September 25, 2017

Hi Max,

actually, you should not use the "key" field but the "name" field (the username). In most cases, they are identical, but after you rename a user, they will diverge.

Also, when the field name contains a space, you can use this alternate form: issue.fields["Brand Manager"]

So the correct expression would be:

{{issue.fields["Brand Manager"].name}}

Finally, because of the asynchronous nature of Cloud post-functions, you might need to add a small delay (using the "Delayed execution" setting of the post-function) if the Brand Manager field is set during the same transition as the Create Issue post-function is run.

Max Andersen September 26, 2017

@David FischerAbsolutely beautiful David - that works fantastically. Thank you.

Is there, to your knowledge, a complete overview of syntax somewhere available or is the only way to find such correct codes to 'know' or to scour boards such as this?

David Fischer
Community Champion
September 26, 2017

Hi @maxandersen,

we have a lot of documentation about that:

However, it might not be sufficient, or not well organized, or not clear enough. Would you have any recommendation for us to make it better? Either the documentation itself, or access to documentation from the add-on's user interface.

Any suggestion (or criticism) is more than welcome!

Thanks,

David

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events