Forums

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

Issue with advanced automation rule

Antonio Carvetta
Contributor
July 5, 2023

Morning community,

I'm trying to create a Jira automation rule to do the following.

I have two custom fields, both drop-down lists:

- Custom Field 1: Client Name(s)

- Custom Field 2: Name

 

I aim to automatically fill out Custom field 2 with the Custom field 1 first value.

Example: 

if Custom field 1 = Jira, Confluence, Cloud, then Custom field 2 would show only Jira

 

I created the following JSON, but it's somehow not working.

 

{
"update": {
"Custom Field 2": [{
"set": { "value": "{{Custom field 1}}" }
}]
}
}

 

Can you please help me out?

3 answers

2 accepted

1 vote
Answer accepted
Evgenii
Community Champion
July 5, 2023

Hi, @Antonio Carvetta 

Please, don't use JSON for such tasks. It can be made with standard functions of smart values.

Your customfield_2 - is standard field with "multiple select from list" type.

In Jira automation you can pull first or last value from list of values in field. Use list.first function. Here you can find examples:

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/

Antonio Carvetta
Contributor
July 5, 2023

@Evgenii my primary issue is how/where to use the 2 custom fields

Antonio Carvetta
Contributor
July 5, 2023

Or would it be something like this?
{
"fields": {
"Custom field 2": "{{#issue.fields.customfield_1}}{{customfield_1.first}}{{/}}"
}
}

Evgenii
Community Champion
July 5, 2023

@Antonio Carvetta you have to add action Edit Issue, select required field, and use there string like:

{{issue.customfield_22222.first.value}}

(change 22222 to your customfield id)

image.png

Antonio Carvetta
Contributor
July 5, 2023

@Evgenii still facing issues. Let me upload an image with the automation. It may help.Screenshot 2023-07-05 at 16.53.54.png

Evgenii
Community Champion
July 5, 2023

Please, don't use section "Additional fields", it's made simplier. Insert my string to field upper, as shown on pic.

image.png

Antonio Carvetta
Contributor
July 5, 2023

@Evgenii followed your guidance - thanks. The query runs but the field remains blank.

Evgenii
Community Champion
July 5, 2023

Ok, try to use {{issue.customfield_22222.first}}

Antonio Carvetta
Contributor
July 6, 2023

@Evgenii still blank!

Evgenii
Community Champion
July 6, 2023

Hi, @Antonio Carvetta 

It's strange. What types of fields are you using? Type of field, from which you try to copy first value, and type of field, where you try to paste it?

I repeated case on my stand, everything works fine

image.pngimage.pngimage.png

Antonio Carvetta
Contributor
July 6, 2023

Let me try to provide further details.


Both fields are 'Select List (multiple choices)

The first custom field contains 100 values, while the second one contains just 20.

I am aiming to perform the following.

If custom field 1 is filled out with 1 specific value - which I imported in custom field 2, reflect the value into the custom field 2.

If custom field 1 is filled out with 2+ values, and the first one is also present in the custom field 2 dropdown list, automatically reflect it into the custom field 2. dropdown list

Does it make sense, or do you want me to draw something up?

thanks

0 votes
Answer accepted
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.
July 6, 2023

Hi @Antonio Carvetta 

What problem are you trying to solve by doing this?  And specifically, what is significant about the "first" value, and what does "first" mean to you?  Simply put, why do this?

Knowing these things will help the community to offer suggestions relevant to the problem you are trying to solve.

Kind regards,
Bill

Antonio Carvetta
Contributor
July 7, 2023

Hi @Bill Sheboy I explained in the above thread. Let me know if it's still unclear.

Thanks.

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.
July 7, 2023

You do not describe "why" (i.e., the problem you are trying to solve).  Regardless...

The suggestion already offered should work, if the different field values are aligned.  The reason is that the id values could be different with two different custom fields, and so values must be used.

Let's try this:  please write the following to the audit log immediately after the rule trigger and then post images of you updated rule showing that write and the audit log details showing the rule execution.

{{issue.your custom field name.first.value}}

If that shows nothing, it is likely you have the incorrect smart value for your field.  To find the correct smart value (or custom field id) for your field, please use this how-to article.  Essentially, you identify an example issue with your field, call the REST API with a browser, and then search for your field. 

Smart values are name, spacing, and case-sensitive, so this will confirm you have the correct one.  If you do not see your field, it is likely not supported by automation rules.

https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

Like Evgenii likes this
0 votes
Antonio Carvetta
Contributor
July 10, 2023

Thanks @Bill Sheboy and @Evgenii . Everything works as expected.

I basically wasn't aware of using the custom field key. It works now.

Suggest an answer

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

Atlassian Community Events