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

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
Accepted answer

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!

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.

@David Fischer [Innovalog]Absolutely 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?

Hi @Max Andersen,

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
Community showcase
Published Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,372 views 0 8
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you