Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Setting a multi-select field based on the parent Jira Project on ticket creation

Kit Friend
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.
September 22, 2020

Hello hive mind!

I've got 0 JSON skills and suspect this is part of what's blocking me :)...

We'd like to do the following:

1. New ticket is created

2. Populate a multi-select custom field with a value matching the project (e.g. if the issue is created in a project called NET, select NET from the field, if the project is DIGI, select DIGI etc)

Currently I'm struggling to work out:

1. How can we read which project the ticket is part of so that we can define this to be the value that's copied down (it doesn't appear to be a default field we can copy a value from) 

2. How can I populate the target multi-select field - it doesn't appear to be available. I've found some community posts that indicate the fix is to use the More Options JSON but I can't find any training for coding novices on what to actually put in it.


Screenshot 2020-09-22 at 19.28.13.png

1 answer

0 votes
Sherry Goyal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 22, 2020

Hello @Kit Friend 

Thanks for writing to us.

I would suggest you to use if/else condition block along with "Issue fields condition".

Trigger: Issue Created

Condition/Action: if -> project equals NET then -> edit issue(choose custom field from drop down  Screen Shot 2020-09-23 at 10.45.52 am.png) and for value, select appropriate value from dropdown out of all the multi-select options you have.

else if -> project equals DIGI then -> edit issue(choose custom field from drop down) and select value from dropdown out of all the multi-select options you have.

No need to use advanced json part.

Something like this:

Screen Shot 2020-09-23 at 10.44.55 am.png

Hope this helps you.

 

Cheers
Sherry

Kit Friend
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.
September 23, 2020

Hey Sherry - I agree but we wanted to try and avoid having 11 nested IF/else equations and do something a bit more dynamic :P 

Is there a tutorial on how to use the JSON option?

Sherry Goyal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 23, 2020

Hello @Kit Friend 

Yes you can achieve this using JSON, something like this: 

 


"update": {
"your_custom_multiselect_field_name": [
{
"set": [{"value": "{{issue.project.key}}"}]
}
]
}

 

For more details and usage with examples, you can refer here.

 

Thanks
Sherry 

Kit Friend
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.
September 23, 2020

Hey Sherry,

Almost there I think. I thought this would work:

{
"update": {
"customfield_10054": [{
"set": [{
"{{project.key}}": "{{issue.project.key}}"
}]
}]
}
}

 and I can successfully write in the Project Key as a label using a similar technique. But when trying to use it to set the content of customfield_10054 I get:

Error editing issues DEMO-42 (Field 'customfield_10054' cannot appear in both 'fields' and 'update')

 

Thoughts?

Sherry Goyal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 23, 2020

You can set value like:

"customfield_11448" : [ { "value": "option1" }, { "value": "option2" } ]

or

"customfield_11448" : [ { "id": 10112 }, { "id": 10115 } ]

So either use value or id not "{{project.key}}" inside set .

Kit Friend
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.
September 23, 2020

Thanks Sherry, that won't fulfil the goal here of setting the field content dependent on what project the trigger ticket is created in though right?

Sherry Goyal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 23, 2020

Let me try it once more :) 

Say there is custom field "brand" which is multi-select field type. So it's possible values are exactly as all project keys.

Then I can create a global rule where I choose trigger "Issue created" and then edit issue action where I set field "brand" as "project.issue.key".

And above json will do just the same, just set the value of "brand" same as project key, independent of project where issue was created(provided list values are exactly the same and all project keys are covered).

I think this is what exactly you are looking for.

Please correct me if I got you wrong.

Thanks.

Like Vikrant Yadav likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events