---
title: "Make an issue read-only"
canonical: "https://support.appfire.com/space/PSJ/15482380/Make%20an%20issue%20read-only"
format: markdown
---
Problem You want to prevent more than one user editing an issue at the same time. To do this, you can use  Live Fields  and  Power Actions™  to make the issue read-only when a user is editing it. Solution When a user clicks  Edit  on an issue, it becomes “locked“ and no other user can edit it until the current user unlocks it. Important Before you begin, have a look at the  Live Fields Configuration . Create a hidden custom field First, create the custom field that indicates the user who locked the issue. Go to  Administration  >  Custom Fields . Add a new custom field and select  User Picker  type. If you want the field hidden, do not select any screen for it. Alternatively, use the Live Fields  lfHide  function. For the purpose of this recipe, the  lfHide  function has been used. Here is an example of the  userPicker  custom field with the  FieldId 13522 . Create the unlock button For the unlock button, create a Power Actions™ Custom Field. Set the name to  Unlock Issue  and assign it only the  Unlock  action. To release the lock, click  Edit Screen Script . Make sure not to set the custom field to any value. customfield_13522 = "";
return; When you click the unlock button, the lock on the issue is released.  Write the initial script The initial script is run when the issue page is loaded. The script verifies if a user is editing the issue.  By default, a user edits the issue when the custom field at the first step is not set to any value. The fields on the issue are unavailable for users without the lock. Only the user who locked the issue can edit it. For the purpose of this recipe, the most important standard Jira fields have been disabled. You can add more fields or custom fields.   In addition, hooks for the editable standard fields have been created. When a user edits an issue, the lock is enabled on it and no other user can edit it. The issue remains locked until the current user clicks the  Unlock  button to release the lock. The  Unlock  button is displayed only for the user who locked the issue. lfHide("customfield_13522");
if (length(customfield_13522) != 0) {
 if (customfield_13522 != currentUser()) {
 lfDisable("issueType");
 lfDisable("priority");
 lfDisable("affectedVersions");
 lfDisable("status");
 lfDisable("resolution");
 lfDisable("summary");
 lfDisable("fixVersions");
 lfDisable("assignee");
 lfDisable("reporter");
 lfDisable("created");
 lfDisable("updated");
 lfDisable("labels");
 lfDisable("editSubmit");
 lfDisable("transitionSubmit");
 lfExecuteJS("ScriptHide.js");
 } else {
 lfExecuteJS("ScriptShow.js");
 }
} else {
 lfExecuteJS("ScriptHide.js");
}
lfWatch("edit-issue", {}, "disable.sil" , {"click"});
lfWatch("issueType", {}, "disable.sil",{"click"});
lfWatch("priority", {}, "disable.sil",{"click"});
lfWatch("affectedVersions", {}, "disable.sil",{"click"});
lfWatch("resolution", {}, "disable.sil", {"click"});
lfWatch("summary", {}, "disable.sil", {"click"});
lfWatch("fixVersions", {}, "disable.sil",{"click"});
lfWatch("assignee", {}, "disable.sil",{"click"});
lfWatch("reporter", {}, "disable.sil",{"click"});
lfWatch("labels", {}, "disable.sil",{"click"}); Write the script for disabling fields This script verifies if the issue has already been locked. If it has not been locked, the current user is assigned the permission to be the only editor at this point. If a different user attempts to edit the issue, a dialog message is displayed. if (length(customfield_13522) == 0) {
 customfield_13522 = currentUser();
 lfExecuteJS("ScriptShow.js");
} else if (customfield_13522 != currentUser()) {
 lfDialogMessage(customfield_13522 + " is editing this issue.", "WARNING");
 lfDisable("issueType");
 lfDisable("priority");
 lfDisable("affectedVersions");
 lfDisable("status");
 lfDisable("resolution");
 lfDisable("summary");
 lfDisable("fixVersions");
 lfDisable("assignee");
 lfDisable("reporter");
 lfDisable("created");
 lfDisable("updated");
 lfDisable("labels");
 lfDisable("editSubmit");
 lfDisable("transitionSubmit");
}  Manage the Unlock button To display the  Unlock  button only for the user who locked the issue, create two JavaScript fields. Run the fields using  lfExecuteJS , as in the scripts above. First, create the  ScriptShow.js  file and enter the following code, where  14500  is the ID of the Power Actions™ custom field: AJS.$('#rowForcustomfield_14500').show(); Next, create the  ScriptHide.js  file and enter the following code: AJS.$('#rowForcustomfield_14500').hide(); Test Log in with  admin  credentials and start editing an issue. The issue is now locked and other users can't edit it.  When you edit the issue, either by clicking the  Edit  button or by inline editing, the  Unlock  button is displayed on the screen. Next, log in with different user credentials (for example,  alina ). You can now view the issue, but can't edit it.  Click  Edit . The following message is displayed. The issue can be edited by user  alina  only after the user  admin  unlocks it. Table of Contents