Forums

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

How to set the assignee to the current value of the multiple choices field

vincenzo.spatafora
Contributor
October 8, 2024

 

Dear ALL,

who can help me out?

I have created an automation rule which triggers upon issue transitioned and the action is simply to update the assignee field with the current value of a multiple choices field (select list) called in my case Responsible.

This rule runs with NO error, indeed, the log reports “Issues edited successfully” BUT nothing has happened actually, I mean, the assignee has NOT changed as I wanted.

 

This is my syntax:

 

{

    "fields": {

        "assignee": { "name": "{{issue.Responsible.name}}" }

    }

}

 

I use Jira DC version 9.12.12.

 

Thanks in advance, Vincenzo.

2 answers

0 votes
John Funk
Community Champion
October 8, 2024

Hi Vencenzo,

Jira doesn't know which value of a multiple value field to get to put in a single assignee. You can do this to get the first value in the multi-field though. 

In the box for the Assignee field, put this:

{{issue.Responsible.get(0).accountId}}

vincenzo.spatafora
Contributor
October 8, 2024

Hi John,

I have tried that out:

no errors but the assignee has not changed and from the log the smart value of {{issue.Responsible.get(0).accountId}} is empty, it's empty also for {{issue.Responsible.get(1).accountId}}.

 

Thanks, Vincenzo.

John Funk
Community Champion
October 8, 2024

Let's try this then:  {{issue.Responsible.get(0)}}

 

 

vincenzo.spatafora
Contributor
October 8, 2024

@John Funk,

fine, now the log is giving the user name, so I use this syntax:

{

"fields": {

"assignee": { "name": "{{issue.Responsible.get(0)}}" }

             }

}

but you get the following error message:

 

Error editing issues
GAL-5919 (User 'Spatafora, Vincenzo' does not exist. (assignee))
Thanks, Vincenzo.
John Funk
Community Champion
October 8, 2024

You don't need to put the code in the Advance section - just put it in the Assignee field. 

vincenzo.spatafora
Contributor
October 8, 2024

same error: the user does not exist

John Funk
Community Champion
October 8, 2024

Can you put that same user in the field directly (manually)?

vincenzo.spatafora
Contributor
October 8, 2024

Hi @John Funk

sure I can edit manually but that's my challenge: I wouldn't know a priori who is going to be the user being responsible of the issue which has transitioned.

Kind Regards, Vincenzo.

John Funk
Community Champion
October 8, 2024

Just trying to make sure that the user you are trying to use actually can be added as the assignee. It's not that I am suggesting that as a solution, just trying to make sure that you can be put into the Assignee field. 

vincenzo.spatafora
Contributor
October 8, 2024

@John Funk, thanks: yes, I'm very sure that the user can be put in the Assignee field.

Like John Funk likes this
John Funk
Community Champion
October 8, 2024

Can you share the audit log of the rule where you get the error?

vincenzo.spatafora
Contributor
October 8, 2024
John Funk
Community Champion
October 8, 2024

Maybe try with another user in the custom field. Maybe use a project Administrator for that project just to ensure all of the permissions. 

0 votes
Radek Dostál
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.
October 8, 2024

So you have a multi select, but you're using a json path to a single value. Of course that won't and shouldn't work.

If it's "multiple choices field (select list)" I would imagine it's an option based field, but I hope it really is a multi user picker?

How do you choose which user to pick from the list and how do you handle a scenario where the list is empty?

 

Consider logging the value you're getting from "{{issue.Responsible.name}}" to see what you're getting.

After that I assume you will need to get a single value from the list like this https://confluence.atlassian.com/automation/jira-smart-values-lists-993924868.html

vincenzo.spatafora
Contributor
October 8, 2024

@Radek Dostál,

yes, it's a multi user picker whose value it's already set within the Jira ticket (for example to me).

NO scenario at all where the list is empty because at the time of creating the ticket I set this field (Responsible) to one of my team member.

The log of {{issue.Responsible.name} is empty actually but then I have logged {{issue.Responsible.value} and the value is the current user (for example myself).

So, I have used the following syntax:

{

"fields": {

"assignee": { "name": "{{issue.Responsible.value}}" }

              }

}

And now you get this error message:

 

Error editing issues
GAL-5919 (User 'Spatafora, Vincenzo' does not exist. (assignee))

Thanks for letting me know,

Vincenzo.  

Radek Dostál
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.
October 8, 2024

Well, just do issue.Responsible.get(0).name as you did - the only difference is the getter by index.

Or issue.Responsible.first.name to make it more "readable".

 

It does surprise me that it would be empty in your original format though. Purely json-syntax wise it is not a valid getter, but A4J documentation makes it seem that it should return the array of names. Meh, either way.. first.name should work.

 

EDIT

Oh also, iirc assignee and users should be mapped by keys.

If this still doesn't work can you try a combination of:

assignee: { "key": {{issue.Responsible.first.key}} }

 

Maybe the docs are confused, or I'm confused, but in any other API it uses keys so I think that might also be a potential thing to look out for.

vincenzo.spatafora
Contributor
October 8, 2024

Thanks @Radek Dostál.

Done that; no errors but no result: the assigneed has NOT changed despite the log says "Issues edited successfully".

Cheers, Vincenzo. 

Radek Dostál
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.
October 8, 2024

Hm, dunno.

These both work though just tried:

setter.png

 

or

 

json.png

 

I'm guessing it's the missing quotes, realized while editing that the smart value returns the "pretty" string without quotes, so you might be probably missing it in your json.

vincenzo.spatafora
Contributor
October 8, 2024

Thanks again @Radek Dostál.

As before: no errors but the assigneed has NOT changed despite the log says "Issues edited successfully". 

Suggest an answer

Log in or Sign up to answer