Automation for Jira: How to find the Root Cause for an unknown Error in the Audit Log for an Automation Rule
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Summary
Sometimes, after creating an Automation Rule, an error can be seen in the Audit Log with an unknown cause. An example would be "Could not find your configured field, it may have been deleted?" for an Issue Action.
This Article will cover how to check the Automation Rule's configuration for the cause of this error and correct it once found without having to wipe the Component or Rule.
Environment
Automation for Jira in Jira Cloud
Cause
The root cause for why an Error might appear in the Audit Log can vary greatly, but in this case, we'll use a simple example.
An Issue Action, such as Create Issue or Edit Issue, is set to copy a Custom Field to an Issue. But the Custom Field has been deleted. This leaves the Issue Action in a state where it will fail to Copy any Value, since the copied Custom Field no longer exists.
This will be our working example for how to use an exported Automation Rule's JSON to find the troublesome Component and quickly hone in on the Source of the Problem.
Solution
To solve our example, we will need to give the Issue Action a new Custom Field to Copy From, or have it Set the destination Custom Field's value directly. It can be difficult to find the Field that needs to be corrected within a large list.
Typically, an Issue Action in this state shows as Copy from Trigger Issue when it should be Copy <field> from Trigger Issue.
The first step will be to Export the Automation Rule to JSON, as mentioned here:
Once the Automation Rule is Exported, open the JSON file in a text editor of your choice. It just needs a way to Find text (i.e. the equivalent of Ctrl-F/Cmd-F).
Note: It can be helpful to format the JSON as this makes reading it much easier. Tools like Visual Studio Code (Alt+Shift+F/Option+Shift+F) or some websites can do this.
After it is open, search for the problematic field's name. In other situations, a different value may need to be searched for. It depends on what the Audit Log provides.
In this case, the field's name should be the one listed in the Audit Log under the Error.
Once the search completes, read in reverse from the reference until two elements are found:
- the part of the Component that contains the reference from the Audit Log that was searched for. In this case, it would be a sourceField that lists the missing Custom Field.
- a string similar to {"id":"12345","component":"ACTION"} as this will provide the ID of the Component that contains the source of the Error. This should be the first instance of one that precedes the reference from the Audit Log that was found.
Next, open the Automation Rule in your Jira Site and click on any Component in it. This should load that Component's ID at the end of the URL bar in your browser:
- https://site.atlassian.net/jira/settings/automation#/rule/<rule-id>/<component-id>
Replace the Component ID in the URL with the ID found from #2 above and press Enter. This should cause the browser to snap to the Component causing the Error.
Finally, use the 1st element to determine which part of the Component needs to be fixed. In our example, the sourceField comes just after the Custom Field that is being Copied to, so we can find that in the Component's list in the UI and select a new Custom Field to be Copied.
This fixes the problem, so the Automation Rule will no longer cause that Error when it runs.