Forums

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

Jira automation: Using smart value in JSON to determine updated field

Joe Morris September 18, 2020

I am running Jira server 8.7.1, and I just picked up the Automation for Jira - Server app from the marketplace.  It seems like a very useful tool!

 

Right now I am trying to use it to revert any change to a number of fields in certain circumstances (i.e. based on the value of another field and the user being in a group or not).

I have written a rule with a "Field value changed" trigger, added the conditions I want, and have an "Edit issue" action.

I have been able to use this rule to revert the value of a single hard-coded field using {{fieldChange.fromString}}.  I was also able to revert that same field by using the "Additional fields" box with the following JSON:

{"fields": {"Coding Developer": "{{fieldChange.fromString}}" }  }

 

While I could write a rule for every single field I want protected, I'd much rather cover them all with this one rule.  It seems like it should be possible just by changing the JSON to this:

{"fields": {"{{fieldChange.field}}": "{{fieldChange.fromString}}" }  }

I have verified that {{fieldChange.field}} outputs the name of the field correctly when used to write to the audit log or send notification emails.  But when I put it in the Edit Issue JSON box, I get this error message: 

"Additional fields contains invalid field(s) in 'update' or 'fields' section: {{fieldChange.field}}"

 

If anyone has any recommendations for how I can use {{fieldChange.field}} in the JSON box, or a suggestion for a different way to accomplish what I want to do, I'd very much appreciate your assistance.  Thank you!

1 answer

0 votes
Joe Morris September 18, 2020

Update: I have brute-forced a method that allows me to have all of the fields handled by a single rule, and only list the conditions and final email notification action once, by using branches to check the changed field name against each individual field name, and if they matched reset the value for that field (see partial picture below; the [branch -> if -> then] pattern is repeated a dozen times).

I eventually realized that it might have been better to use an if/then/else condition structure, but I'm not sure because I haven't tried it yet.  Either way, I'd be a lot happier if I could just use one JSON action as described in my initial post, so I'd still very much like it if anyone has a suggestion as to how to do so.  :-)

Untitled picture.png

Suggest an answer

Log in or Sign up to answer