How do I have condition for each "when value changes"?

Jar Lady
Contributor
April 14, 2024

I have multiple fields to watch for changes. However, I would like to state all these in one Jira automation rule such that:

When any of the 5 fields (A/B/C/D/E) change:

If field 1 changes, retrieve old + new field value + do action A

If field 2 changes, retrieve old + new field value + do action B

Is this possible?

2 answers

0 votes
Ste Wright
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 14, 2024

Hi @Jar Lady 

So there's essentially 5 actions? One per field? If yes, why don't you want to use 5 separate rules?

If no, could you detail more of the possible variations?

Ste

Jar Lady
Contributor
April 15, 2024

No, I don't just have 5 fields. I have more than that, but I am just citing 5 as example.

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.
April 14, 2024

Hi @Jar Lady 

I suspect that depends on the actions you want to perform and the field types...

All of the fields could be selected in the Field Value Changed trigger, and then followed by an if / else structure of conditions to check the changelog for differences for each field.

However, some fields do not appear to correctly / consistently update the changelog accessible to rules.  And if you are performing complicated actions for each case, the use of the if / else may prevent that due to rule limitations.

I recommend creating a test rule, only writing to the audit log rather than performing any other actions, and test what works for your fields.

Kind regards,
Bill

Jar Lady
Contributor
April 14, 2024

So.. what is the solution? 

I need an automation rule that is configured to the abv:

When any of the 5 fields (A/B/C/D/E) change:

If field 1 changes, retrieve old + new field value + do action A

If field 2 changes, retrieve old + new field value + do action B

How do I set this: "If field 1 changes" portion and also retrieving old and new field value.

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.
April 14, 2024

I already suggested a solution approach: try using the changelog values:

https://confluence.atlassian.com/automation/jira-smart-values-issues-993924860.html#Jirasmartvaluesissues-changelogchangelog

If that does not help, I recommend contacting your Jira Site Admin for assistance.

Jar Lady
Contributor
April 14, 2024

I appreciate the help but I looked through the doc and there is no example how to apply in Jira automation rule. It 'll be great if an example of configuration of the changelog values in my use case. Precisely cos the documentation doesn't really help due to the limited example. I will need to access each field's difference first before I can set a condition. But changelog is entire fields that have been changed.

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 14, 2024

@Jar Lady  - I would suggest giving Bill's suggestion a try and then post a screen shot of your rule so that we can further help troubleshoot. Bill is the GOAT of Automation Rules so don't just discount his suggestion without trying it first. 

Jar Lady
Contributor
April 14, 2024

Unfortunately my trial license has expired so I can't use the Jira software online. I did not discount his suggestion but rather I don't know how to apply the changelog smart values at all. The documentation did not show clear syntax of how do I retrieve particular fields. If I didn't know what is the syntax how do i even write? The documentation lack the mention of the field name, so on what basis do I even use it to write:

changelog

{{#changelog.summary}}
  {{toString}}
{{/}}
{{#changelog.issuetype}}
  {{fromString}}
{{/}}
// Previous status name
{{#changelog.status}}{{fromString}}{{/}}
// Previous status id (for using in another Edit action
{{#changelog.status}}{{from}}{{/}}

Sometimes it's better to write out the syntax instead of theory because the understanding of theory is very subjective...

Also, how do I use changelog to retrieve each index of a multiple people field? For example, I have a field called People and it consists of Person A, Person B. How do I get the past value of Person A and Person B? What syntax to use? 

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 15, 2024

Free licenses don't expire. That will last as long as you keep using the product. 

Where you see the words summary or issuetype above, those are the field names. It is just that they are system fields so they look a little different. You should use the EXACT name of your field there, including case. 

Jar Lady
Contributor
April 15, 2024

My example was making use of custom field, hence it could be using either changelog.customfield_`12345 or changelog."field name" but it wasn't clear on the syntax.

Which is why it's back to my point above, it will be great to have example tailored to my use case rather than reading the documentation because the understanding of documentation is subjective (and based on general scenario) and doesn't facilitate 2-way conversation. Before asking the question, I already did my research on the documentation but couldn't find a clue. Even so... I can't find anything related to accessing the index of the changelog custom field value if it is configured as multiple. I tried changelog.custom field name.get(0) but it did not retrieve just the first value  I see in the multi-people field.

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 15, 2024

Right, which is why it is best for you to give it a shot first and post a screenshot of your rule so we can tailor the answer to your case.  :-)

 

Jar Lady
Contributor
April 15, 2024

Yes, I had tried in my other environment. printing out {{#changelog.field name.get(0)}} doesn't work as it returns whole list of People. 

changelog people.PNG

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.
April 15, 2024

Hi!

Earlier I noted the field type impacts detecting changes to a field.  And although the Issue Field Updated or generic Issue Updated triggers usually work to detect the change, the specific values to check are determined by the field type:

For a text, label, or date fields, this would work (substituting the correct smart value):

compare if {{#changelog.fieldSmartValue}}{{fromString}}{{/}} does not equal {{#changelog.fieldSmartValue}}{{toString}}{{/}}

 

The changelogs do not always work in rules for list / multiple selection fields due to a known defect, and so checking those may not help.

To learn if they work for your fields, try {{fieldChange.from}} and {{fieldChange.to}} smart values to compare the raw values: https://confluence.atlassian.com/automation/jira-smart-values-issues-993924860.html#Jirasmartvaluesissues-fieldChangefieldChange

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.20.10
TAGS
AUG Leaders

Atlassian Community Events