Forums

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

Can you help me with a smart value needed for comment added through automation?

William Wightman January 26, 2024

Hello, 

I am hoping someone can help with me with the smart values needed to build an automation rule. 

 

The automation rule will trigger when an issue is created. After going through a few issue fields condition, it will create a comment to be added to the issue.

 

The part that I need help with is I want text/links to display in the comment, but only when a certain field is selected in a multi-select field. For instance.

 

If Custom ID Field XXXXXX contains "Red" then display:

Red - www.red.com

 

If Custom ID Field XXXXXX contains "blue" then display:

www.blue.com

 

There are too many different scenarios for me to build this into the automation rule itself so was hoping to accomplish it this way.

 

I have a similar rule set up but this ones only displays if the custom field is not empty

 

{{#if (issue.fields.customfield_XXXXXX.isNotEmpty()) }}
<b>Approval Conditions (Billing)</b>: {{issue.fields.customfield_XXXXXX}}
{{/}}

 

Can something similar be accomplished but instead of "is not empty", can it be "contains".

 

Any help you can provide is appreciated! Please let me know if you have any questions.

1 answer

2 votes
Jehan Bhathena
Community Champion
January 26, 2024

Hi @William Wightman ,

In order to read the value from and match it to a certain string/regex you need to use match() in the smart value.

Ref : https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#match--

A quick google search will give you plenty of examples of how to use the above, for your use case it should be something like this "issue.fields.customfield_XXXXXX.match("red")", if this is TRUE then the loop should run with the required output.

Do let me know if this works out for you.

William Wightman January 29, 2024

@Jehan Bhathena Thank you for the quick response on this! 

Unfortunately, I was not able to get this to work. I am fairly new to smart values and think I may be doing something wrong.

This is the error I am receiving:

Capture1.29.PNG

This is how I set the comment in the rule:

 

Capture1.29.2.PNG

{{#if (issue.fields.customfield_XXXXX.match("Red"))}}
The color is Red.
{{/}}

{{#if (issue.fields.customfield_XXXXX.match("Blue"))}}
The color is Blue.
{{/}}

{{#if (issue.fields.customfield_XXXXX.match("Green"))}}
The color is Green.
{{/}}

 

For the issue, I ensured that 2 selections were included in the custom field when testing.

Do you see anything quickly that may be incorrect?

Thank you!

William

Please note: I had to replace the actual names/text with colors due to our policies.

Jehan Bhathena
Community Champion
January 30, 2024

Hi @William Wightman ,

The syntax for the custom field was incorrect (my bad)

https://community.atlassian.com/t5/Jira-Service-Management/how-to-add-Custom-Field-Smart-Value/qaq-p/1976220#M100981

Try using this : (customfield_XXXXX.match("Green")).

I would also suggest using the action "Log Action", and print the value that is stored in the above field eg.

{{customfield_xxxx.value}}

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

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