Automation: Set custom field to user input dropdown value

Fabien January 22, 2024

I've created a manually triggered automation with a user input dropdown field called "Team" (referenced as {{userInputs.team}}) with values "Team 1" and "Team 2" (the names of my Advanced Roadmaps teams).

I want to use the selected value of said dropdown in a "Create issue" action to set the according "Team" field (which for some reason is not available in the "Choose fields to set..." list so I'm trying to set it using "Additional fields" - it is however available on the create screen of the according issue type).

My current "Additional fields" content looks like this:

{
"fields": {
"Team": {
"value": "{{userInputs.team}}"
}
}
}

 

However, when executing said rule I get the error
The team id "JsonData{data={value=Team 1}}" is invalid. (customfield_10001)

I tried using {{userInputs.team.value}}, {{userInputs.team.data.value}}, {{userInputs.team.asJsonObject.data.value}} and pretty much every single combination of all the functions recommended by the smart value online help. But for some reason I can't find a way to access the actual selected value ("Team 1").

I've tried to use the field in a {{smartValue}} if block and a comparison there seems to work, but the current structure of my automation makes it really cumbersome to use it that way at said position in the automation.

My final goal is to create a manual trigger on Support issues to create and link a bug by only selecting the team and the project to create the Bug in. I solved the project part by using an if/else block on the aforementioned second user input field (since "Project" can't be set programmatically in "Create issue" actions).

3 answers

1 accepted

0 votes
Answer accepted
Fabien January 24, 2024

For future reference - at least in the current version of Jira I had to set the Team field directly for it to work - as in:

{
"fields": {
"Team": "55063845-50cd-46fa-ba80-7857298897be"
}
}

It works with a lookup table as well (which has to be created within the same automation before said step):

{
"fields": {
"Team": "{{teamNameToId.get(userInputs.team)}}"
}
}

What doesn't work is directly assigning the name of the team:

{
"fields": {
"Team": "Team 1"
}
}

This leads to an internal server error during automation execution.

0 votes
Rudy Holtkamp
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 22, 2024

Hi @Fabien ,

You should use the id of the team:

{
"fields": {
"Team": {
"id": "XXXX"
}
}
}

If you use a lookuptable (e.g. projectNameToId) you can use that to translate the name of the team to the id.

Id's of the team can be found if you go to the team menu and take the number in the URL after team. E,g, https://xxx.atlassian.net/jira/people/team/1d4ff324-f3e4-4f01-aff5-ce5613cdfe43

Where 1d4ff324-f3e4-4f01-aff5-ce5613cdfe43 is the team id.

Then {{projectNameToId.get(userInputs.team)}} instead of the XXXX, which leaves:

 

{
"fields": {
"Team": {
"id": "{{projectNameToId.get(userInputs.team)}}"
}
}
}

 

Good luck

Fabien January 23, 2024

I think I got closer with this one - however I still run into the following issue:

For simplicity's sake I reduced the case to two teams and use the following code (whether I use "Team" or "customfield_10001" seems to not matter)):

{
"fields": {
"customfield_10001": {
"id": "{{if(equals(userInputs.team, "Team 1"), "55063845-50cd-46fa-ba80-7857298897be", "030e8d46-e3b3-4249-a499-1130ff0963a0")}}"
}
}
}

If I select "Team 1" in the dropdown the equals returns true and the if therefore returns the first team id. However, even though I have issues in the selected project assigned to the team with that id, I get the error

The team id "JsonData{data={id=55063845-50cd-46fa-ba80-7857298897be}}" is invalid. (customfield_10001)

Any idea why?

Fabien January 23, 2024

The problem seems to lie deeper - even if I try to set the id directly:

{
"fields": {
"customfield_10001": {
"id": "55063845-50cd-46fa-ba80-7857298897be"
}
}
}

I get the same error. I also tried to reference the field by name ("Team") or set the "value" instead of "id". I always get the same error. I verified the team id 3 times by now, the team id is definitely correct and if I set the team manually on an existing issue in that project I see a PUT request for that issue containing said id.

Rudy Holtkamp
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 26, 2024

@Fabien This is a reply on your first comment above:

{
"fields": {
"customfield_10001": {
"id": "{{if(equals(userInputs.team, "Team 1"), "55063845-50cd-46fa-ba80-7857298897be", "030e8d46-e3b3-4249-a499-1130ff0963a0")}}"
}
}
}

This is invalid, because you have used the double quotes two times. I think it should be:

{
"fields": {
"customfield_10001": {
"id": {{if(equals(userInputs.team, "Team 1"), "55063845-50cd-46fa-ba80-7857298897be", "030e8d46-e3b3-4249-a499-1130ff0963a0")}}
}
}
}

 (Strip the doubles in front of the {{if and after }}  )

But your next comment showed me that the JSON I proposed does not work. So I tried myself and saw that it indeed not worked (I got the same cryptic error message). Fortunately this does work for me:

{
"fields": {
"Team": "305e83e6-a643-45f6-8279-b74eb8f2cff9"
}
}

Which  for you means, that this should work:

{
"fields": {
"customfield_10001": {{if(equals(userInputs.team, "Team 1"), "55063845-50cd-46fa-ba80-7857298897be", "030e8d46-e3b3-4249-a499-1130ff0963a0")}}
}
}

 

Regards,

Rudy

0 votes
Bill Sheboy
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.
January 22, 2024

Hi @Fabien 

I recall the advanced roadmap fields are not fully supported by automation rules, and the custom field id value may be used, rather than the field name, in an advanced edit with JSON.

Please use this how-to article to determine your Team field's custom field id: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

Kind regards,
Bill

Fabien January 23, 2024

This doesn't seem to be the problem. It correctly identifies the field as "customfield_10001" and it makes no difference whether I reference it as "Team" or "customfield_10001".

Bill Sheboy
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.
January 23, 2024

Thanks for that information.  A couple of more things to try:

First, is that Team field single or multiple select for the issue?  The JSON syntax is different if this is multiple select: https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Multi-select-custom-field

Next, have you tried to simplify the conditional part (of using the team id) with a Lookup Table?

https://community.atlassian.com/t5/Automation-articles/New-Automation-action-Create-lookup-table/ba-p/2311333

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events