Help with Automation to set a field value based on certain criteria

Juliette Bramall February 7, 2025

Hello fellow Atlassian-ers :) 

We have a custom field called 'Closing Category', a field called 'Test Phase' and a third field called 'Root Cause' for a bug issue type. 

 

I've been asked to automate the 'Closing Category' which requires a conditional update based on "Root Cause" field as below,

If (Test Phase is " User Acceptance Testing" or "Production") and Status is "Closed" then
{
if (Root Cause = "Cutover") then Closing Category = "Production Deployment / Cutover Issue"
if (Root Cause = "Duplicate" then Closing Category = "Invalid"
if (Root Cause = "Existing Production") then Closing Category = "Existing Production issue"
if (Root Cause = "Invalid Defect") then Closing Category = "Invalid"
if (Root Cause = "Non Reproducible") then Closing Category = "Cannot be tested, no clear recreation, speculative fix"
if (Root Cause = "Requirements/Specification") then Closing Category = "Requirements change raised in pilot or rollout"}

Can anyone else me set up the automation, including triggers and components, etc. I'm a bit of an automation novice when it's anything beyond the basic :) 

Thanks in advance!

2 answers

0 votes
Juliette Bramall February 10, 2025

sorry, IScreenshot 2025-02-10 120929.png thought I had. Here it is 

0 votes
Vishal Biyani
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.
February 7, 2025

@Juliette Bramall 

Please share more context for community to help you.

  • How are the values populated in Custom field "Root Cause" and "Test Phase"? is it on a status Transition of the issue or is updated manually?
  • Is the automation rule applicable for a specific issue type?
Juliette Bramall February 7, 2025

Hello @Vishal Biyani 

  • Yes, it's on transition from the status Retest to the Closed status. 
  • It's for bug issue types
Vishal Biyani
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.
February 7, 2025

@Juliette Bramall 

Please implement these steps and share your automation rule screen shot if you face hurdle.

1. Trigger

Add Issue Transitioned trigger

  • In from status add Retest (Should exactly match your status name)
  • In To status add Closed

2. Click on Add Action and search for Add If condition

if issue type equals Bug

3.  Add Lookup Table

Click on Add an Action and search for lookup table

  • Provide lookup table variable name say ClosingCategory
  • specify your conditions for root cause e..g key = Cutover value = Production Deployment / Cutover Issue

4. Click on Add Action and search for Add if block 

In Conditions add

Field = Test Phase

Equals User Acceptance Testing

or

Field = Test Phase

Equals Production

5. Click on Add Action and search for Create Variable

Name the variable say RootCause and in smart value put

{{ ClosingCategory.get(issue.Root Cause) }}

5. Click on Add Action and search for Edit issue

In Choose field select Closing Category

and in the text box below put {{ RootCause }}

 

Let me know if this works for you.

When the transition happens, then you should see Closing Category updated.

 

 

Juliette Bramall February 7, 2025

Step 2. Add If condition didn't appear when searched for?

Juliette Bramall February 7, 2025

Screenshot 2025-02-07 124402.pngDo you mean this for step 2. ?

Juliette Bramall February 7, 2025

If the above is correct for step 2. What do I need to do at this stage please?

Screenshot 2025-02-07 124648.png

Vishal Biyani
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.
February 7, 2025

Assume you have added Trigger. This is how it would look

snip.png

Click on + Add Component and on right side you will see a screen like this

snip.png

Click on IF: Add a condition

Then you will see a screen like this 

snip.png

select Issue fields condition highligted

 

Like Juliette Bramall likes this
Juliette Bramall February 7, 2025

I think I've done step 2. And am now looking at step 3. But unsure what to do for the key and value table entries. 

Screenshot 2025-02-07 132416.png

Vishal Biyani
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.
February 7, 2025

Variables need to be without spaces i.e. one word. So it should be ClosingCategory 

in key enter enter Cutover and in value add Production Deployment / Cutover Issue

then click on + Add Entry to add remianing 5 values

 

Key Value
Cutover Production Deployment / Cutover Issue
Duplicate Invalid
Existing Production Existing Production issue
Invalid Defect Invalid
Non Reproducible Cannot be tested, no clear recreation, speculative fix
Requirements/Specification Requirements change raised in pilot or rollout}
Juliette Bramall February 10, 2025

Thank you so much for your help so far @Vishal Biyani 

This is what I've set up. However, when I've tested it out by creating a bug with the relevant field options set as follows:

Root cause = cutover

Test phase = production

However the rule is not running according to the audit log and the Closing Category remains as 'none'.


Juliette Bramall February 10, 2025

Screenshot 2025-02-10 104832.pngScreenshot 2025-02-10 104853.pngScreenshot 2025-02-10 104902.pngScreenshot 2025-02-10 104916.pngScreenshot 2025-02-10 104932.pngScreenshot 2025-02-10 105258.png

Vishal Biyani
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.
February 10, 2025

Can you share the audit log to understand where the rule is not hitting? Audit log is right besides Rule Details

Juliette Bramall February 10, 2025

Screenshot 2025-02-10 110838.png

Juliette Bramall February 10, 2025

You can see it's not even 'firing'.

Vishal Biyani
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.
February 10, 2025

in the rule you have missed starting and ending curly braces

snip.png

Juliette Bramall February 10, 2025

I've updated it as per attached. And re-tested the rule, but it's still not 'firing'?

Screenshot 2025-02-10 111626.pngScreenshot 2025-02-10 111653.png

 

Vishal Biyani
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.
February 10, 2025

can you share the trigger for your rule?

Juliette Bramall February 10, 2025

Screenshot 2025-02-10 120929.pngHere it is. 

Vishal Biyani
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.
February 10, 2025

So you need to execute this transition on a bug that has Status Fixed to Closed. then only automation will get triggered.

 

The bug SS that you shared is already in Done status. So in this case the automation will not get triggered

Juliette Bramall February 10, 2025

I realised it wasn't triggering the rule as I've used the wrong transition. This is now corrected to be Retest to Closed.
Screenshot 2025-02-10 123156.png


 

So the audit log is showing 'success'. 

Screenshot 2025-02-10 123247.png

However, the Closing Category is still blank/none

Screenshot 2025-02-10 123342.png

Vishal Biyani
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.
February 10, 2025

This is good progress.

Can you expand the audit logs to understand where the issue is not meeting the condition?

Do validate that your case matches. Otherwise, string comparison may not work and hence field is not getting set.

Juliette Bramall February 10, 2025

Thank you for your patience with me :) 

Here's the audit expansion. In the meantime I'll validate my case matches. 

Screenshot 2025-02-10 124809.png

Vishal Biyani
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.
February 10, 2025

Looks like Root Cause variable is not getting value. Add more log statements to check where the conditions are failing and go from there.

Juliette Bramall February 10, 2025

Can you clarify what you mean by "Add more log statements to check where the conditions are failing and go from there" please Vishal

Vishal Biyani
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.
February 10, 2025

So wherever smart values are being created, enclose them in {{#debug}} {{/}

for example, for RootCause

{{#debug}}  {{ ClosingCategory.get(issue.Helper Issue Creation) }} {{/}

When automation is executed and value is not getting set you know the problem

BTW, WHY are you using Helper Issue Creation, you need to give your custom field name. What i gave you was an example that i created based on available fields in my instance.

Juliette Bramall February 10, 2025

I haven't used Helper Issue Creation ?

I've tried adding the debug here but am getting an error.Screenshot 2025-02-10 140932.png

Vishal Biyani
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.
February 10, 2025

Add one more } at the end. 

 

 

{{#debug}}  {{ ClosingCategory.get(issue.Helper Issue Creation) }} {{/}}

Juliette Bramall February 10, 2025

Thank you. That's now worked.
This is the latest audit log, with the debug added. 

 

Screenshot 2025-02-10 143109.png

Vishal Biyani
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.
February 10, 2025

Log shows you are getting Cutover as the value, so you are not using lookup table, while creating the RootCause variable.

Can you revisit your rule.

Juliette Bramall February 11, 2025

Screenshot 2025-02-11 081649.pngThis is the table set-up. Is this not correct?

Vishal Biyani
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.
February 11, 2025

Table is fine. Check and share what you have in RootCause? it should be using the lookup table

Juliette Bramall February 11, 2025

Screenshot 2025-02-11 083646.pngThe id is Root Cause field.

Vishal Biyani
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.
February 11, 2025

it should be like this
{{#debug}} {{ ClosingCategory.get(issue.customfield_19832) }} {{/}}

Juliette Bramall February 11, 2025

I've updated it Screenshot 2025-02-11 094337.png

And re-run the automation with a new test bug issue. But the Closing Category is still not populating. 

Screenshot 2025-02-11 094325.png

Screenshot 2025-02-11 094621.png

Vishal Biyani
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.
February 11, 2025

Can you share the SS of the last step i.e edit issue Field?

 

Also, share the history of what Updates happened after the automation was run

Juliette Bramall February 11, 2025

Screenshot 2025-02-11 112109.png

 

 

 

The only update since last running the automation was updating to this :

 

{{#debug}} {{ ClosingCategory.get(issue.customfield_19832) }} {{/}}

Vishal Biyani
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.
February 11, 2025

if you see the log message, RootCause is not getting value.

Add debug statement for issue.customfield_19832 to see what value it is having

Juliette Bramall February 11, 2025

I already have that in place for the variable. Do I also need to add it for the Edit issue fields?

Screenshot 2025-02-11 163808.pngScreenshot 2025-02-11 163834.png

Vishal Biyani
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.
February 11, 2025

add a log statement specifically for  issue.customfield_19832

Need to see what else needs to be added to this variable to ensure it is picking right value

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events