In this example, you will create a live fields configuration that makes a custom field Read Only for any user who is not a Project Lead.
Note: the script included below contains a placeholder reference to a custom field - customfield_12345. You should replace this with your own custom field ID!
To add a live fields configuration:
Log into your Jira instance as an Administrator.
Either:
In the menu bar, click Apps > Live Fields. or
In the upper right corner, click Settings ⚙️ > Apps.
In the left-hand panel, click Live Fields.
Click Create live fields in the upper right corner.
Give the custom field a name and, optionally, a description.
For Screens, select Issue create view and Issue view.
Click Projects, and then click Select projects in the right-hand panel.
Select the project or projects to which your configuration should be applied.
Click Issue types, and then click Select issue types in the right-hand panel.
Select the issue types to which your configuration should be applied (for example, Story and Task).
Under THEN, click Add Scripted action, and then click Start scripting in the right-hand panel.
Enter the following script:
// Make the "Priority" field editable only for the Project Lead
// Get the current user context, including accountId and project details
const context = await getContext();
const { accountId, extension: { project } } = context;
// Fetch details of the current project using its ID or key
const projectDetails = await JiraApi.ProjectsService.getProject({ projectIdOrKey: project.id });
// Get the project lead information from the project details
const projectLead = projectDetails.lead;
// Allow editing of the custom field only if the current user is the project lead
if (accountId === projectLead.accountId) {
getFieldById("customfield_12345").setReadOnly(false); // Make field editable
} else {
getFieldById("customfield_12345").setReadOnly(true); // Make field read-only
}