Forums

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

Set assignee from Reporter

Tereza Červinková
Contributor
May 24, 2021

Hello there,

using Jira Cloud I am thinking of how to set a JMWE using Nunjucks to:

  • set Assignee to Person 1 if the reporter is Person 1 or Person 2 OR ELSE set it to Person 3 if the reporter is different.

Now I know there is an Assign to a Project Role part, but I need to avoid adding new project roles and post-function Build your scrtipt seemed fine.

Now I've gotten here:

{% if issue.fields["Reporter"].accountId == "accountId:5cd52aaf8ad0f60dca007cef" or issue.fields["Reporter"].accountId == "accountId:5cd44f0df58d4f0dc512d7f5"%}
{% set issue.fields.assignee.accountId = "accountId:5cd52aaf8ad0f60dca007cef" %}
{% else %}
{% set issue.fields.assignee.accountId = "accountId:5da42f701a43fe0ddbb43bab" %}
{% endif %}

Accounts in code - first is Person 1, then Person 2
set Person 1
else Person 3

But getting error while testing:

Message:
(string)
  TypeError: Cannot read property 'charAt' of undefined

Can anyone help?

3 answers

2 accepted

3 votes
Answer accepted
David Fischer
Community Champion
May 24, 2021

Hi @Tereza Červinková ,

you need to use a Set Field Value post-function instead, with this value:

{% if issue.fields["Reporter"].accountId == "accountId:5cd52aaf8ad0f60dca007cef" or issue.fields["Reporter"].accountId == "accountId:5cd44f0df58d4f0dc512d7f5"%}
accountId:5cd52aaf8ad0f60dca007cef
{% else %}
accountId:5da42f701a43fe0ddbb43bab
{% endif %}
1 vote
Answer accepted
Tereza Červinková
Contributor
May 24, 2021

Thank you, @Alexander Bondarev and @David Fischer  for your help.

The set field value would definitely help me with that, though I have tried the original code, edited it and now it works. So now it is:

{% if issue.fields.assignee.accountId == "accountId:5cd52aaf8ad0f60dca007cef" or issue.fields.assignee.accountId == "accountId:5cd44f0df58d4f0dc512d7f5"%}
{{ issue.fields.assignee.accountId }} = "accountId:5cd52aaf8ad0f60dca007cef"
{% else %}
{{ issue.fields.assignee.accountId }} = "accountId:5da42f701a43fe0ddbb43bab"
{% endif %}
0 votes
Alexander Bondarev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 24, 2021

Hi, @Tereza Červinková !

Unfortunatelly, I have never used JMWE in Cloud =(

Have you already checked examples from documentation - Use cases for post-functions . 

Also you can raise a supprort request on Customer Portal?

Suggest an answer

Log in or Sign up to answer