Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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!

Include Page
[Includes] Add a live field configuration
[Includes] Add a live field configuration
  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: 

    Anchor
    lf-useCase-ProjectLead-EditOnly
    lf-useCase-ProjectLead-EditOnly

    Code Block
    // 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
    }

Aura inline button
summaryBack
paramsJTdCJTIybGFiZWwlMjIlM0ElMjJCYWNrJTIyJTJDJTIyc2l6ZSUyMiUzQSUyMm1lZGl1bSUyMiUyQyUyMnNoYXBlJTIyJTNBJTIyYW5ndWxhciUyMiUyQyUyMnN0YXRlcyUyMiUzQSU3QiUyMmlkbGUlMjIlM0ElN0IlMjJjb2xvcnMlMjIlM0ElN0IlMjJiYWNrZ3JvdW5kJTIyJTNBJTdCJTIybGlnaHQlMjIlM0ElMjIlMjMwMkI0QzElMjIlN0QlMkMlMjJsYWJlbCUyMiUzQSU3QiUyMmxpZ2h0JTIyJTNBJTIyJTIzZmZmZmZmJTIyJTdEJTJDJTIyb3V0bGluZSUyMiUz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