Skip to end of banner
Go to start of banner

Create a live field configuration

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

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:

  1. Log into your Jira instance as an Administrator.

  2. Either:

    1. In the menu bar, click Apps > Live Fields.
      or

    2. In the upper right corner, click Settings ⚙️ > Apps.

    3. In the left-hand panel, click Live Fields.

  3. Click Create live fields in the upper right corner.

  4. Give the custom field a name and, optionally, a description.

  1. For Screens, select Issue create view and Issue view.

  2. Click Projects, and then click Select projects in the right-hand panel.

  3. Select the project or projects to which your configuration should be applied.

  4. Click Issue types, and then click Select issue types in the right-hand panel.

  5. Select the issue types to which your configuration should be applied (for example, Story and Task).

  6. Under THEN, click Add Scripted action, and then click Start scripting in the right-hand panel.

  7. 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
    }

Next up: Feature comparison

You are viewing the documentation for Jira Cloud.

useCase-OnlyProjectLeadEditField.png

  • No labels