Setting a multi-select field based on the parent Jira Project on ticket creation
Asked by Kit Friend:

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.  

<br />

![Screenshot 2020-09-22 at 19.28.13.png](/t5/image/serverpage/image-id/111361iEE9AF1AC327AE75E/image-size/large?v=v2&px=999 "Screenshot 2020-09-22 at 19.28.13.png")


Answers:
author: Sherry Goyal
body: Hello [@Kit Friend](/t5/user/viewprofilepage/user-id/1002046)

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](https://community.atlassian.com/t5/image/serverpage/image-id/111403iBE2E576491AA0E77/image-dimensions/125x23?v=v2 "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](https://community.atlassian.com/t5/image/serverpage/image-id/111402i94FB155E5FBF696B/image-dimensions/595x335?v=v2 "Screen Shot 2020-09-23 at 10.44.55 am.png")

Hope this helps you.

Cheers  
Sherry

comments: author: Kit Friend
body: 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?


author: Sherry Goyal
body: Hello [@Kit Friend](/t5/user/viewprofilepage/user-id/1002046)

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.](https://support.atlassian.com/jira-software-cloud/docs/advanced-field-editing-json/)

Thanks  
Sherry


author: Kit Friend
body: 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?


author: Sherry Goyal
body: 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 .


author: Kit Friend
body: 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?


author: Sherry Goyal
body: 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.


Tags: cloud