How to revert a Custom Field value when edited by unauthorised users using automation

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

Currently there's no native functionality to restrict users from editing specific custom fields. We have a feature open to enable this functionality in the future:

However we have a workaround using Automation which doesn't restrict but reverts the value of a custom field when edited by unauthorised users.


Warning

  1. The approach in this knowledge base article might not be applicable to all field types found within Jira.
  2. Atlassian Support does not necessarily endorse this method of restriction in all use cases as it could cause end users to become frustrated that their changes to not take affect, and in turn could a high volume of automation executions.


Environment

Cloud

Solution

For this document we will assume a scenario to only allow members of the Administrators role or a specific user (Agent 1) to be able to edit custom field values after the issue is created. This workaround can be used as the foundation for various situations.

Here is a step by step guide to create an automation rule that will trigger when anyone makes any changes to a specific custom field and if the user is not part of Administrator role or the user Agent 1 then it will revert the value of the field to the initially recorded value:
(Please click through each tab)

Use the "Field value changed" trigger

  1. Select the custom field/s that you want the automation to monitor for changes

  2. Ensure the Change type is set to Any changes to the field value

  3. In the For dropdown list, select the operation/s that you want the automation to monitor for changes. In this example, we are using just Edit issue


Add an "If block" with "User condition"

  1. Under Run actions if.. we will be using the At least one condition matches

    Depending on the number of conditions required for a particular user, the Run actions if.. selection will differ

  2. In the User conditions, select User who triggered the event

  3. For the first user condition, as one of the condition is to allow edits to users whom are members of the Administrators role, we will use "is in role" and select the role Administrators

  4. For the second user condition, we will use "is" and select the user Agent 1

You may have noticed that we are not using negative operators such as is not in role is not. This is intentional as negative operators does not seem to work properly with multiple conditions.

Add the "Log action" under the If condition branch

  • As we cannot use negative operators and conditions in automation must have an action, we've opted to use the Log action as it does not alter any values/settings. 

  • In this example, we are logging the before/after changes in a value using the following smart values
Initial value - {{fieldChange.fromstring}} 
Modified value - {{fieldChange.tostring}}

This provides extra logging to find out what the previous value for a field was, in case the user whom has permission to edit the field has made a mistake and needs to revert the change.

Click on "Add else" to add "Else block"

  1. This where we define the action for users whom aren't either
    • a member of the Administrators role
      or
    • Agent 1

  1. As there aren't any conditions that need to be matched for every other user we can leave the block empty and just click Save


Add the" Edit issue" action under the Else condition branch

  1. Select the field/s in Choose fields to set... 
    Should be the same fields as what was selected in the Field value changed trigger

  2. Enter the smart value in the input field
{{fieldChange.fromString}}

Give your automation rule a meaningful name and don't forget to turn it on

Reach out to support for any additional questions: https://support.atlassian.com/

Last modified on May 13, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.