Automatic Assign User from Project Roles to the Approver Field in Jira

Summary

To fetch the users from the project role and update that users in the "Approver" custom field.

Environment

Jira Service Management

Solution

To achieve this requirement we will use Jira Automation.

  • Add a Trigger:
    • Choose a trigger based on your workflow. Some common triggers are:
      • Issue Created
      • Issue Commented
      • Manual Trigger
    • Configure the trigger as needed for your project.
  • Add Web Request Action:
    • Click on Add Action and select Send Web Request.

    • Use the API Get project role for project endpoint to fetch project role

      Enter the following details:

      Web Request URL: https://<site/instance URL>/rest/api/3/project/{projectIdOrKey}/role/{id}
      HTTP Method: GET
      Web Request Body: Empty
      Headers: Content-Type        application/json
                         Authorization        Basic <EMAIL>:<API_TOKEN> - with base64. We can make this through any online tool like Base64 encode.

      Important: Check the box "Delay execution of subsequent rule actions until we've received a response for this web request."


  • Add Action: Select "Log Action" and enter the below value

    {
      "update": {
        "customfield_10003": [
          {{#webResponse.body.actors.actorUser}}
          { "set": { "id": "{{accountId}}" } } {{^last}}, {{/}}
          {{/}}
        ]
      }
    }
    
    


  • Add Action: Select "Edit Issue" and enter following value under "More Action":

    {
      "update": {
        "customfield_10003": [
          {{#webResponse.body.actors.actorUser}}
          { "add": { "id": "{{accountId}}" } } {{^last}}, {{/}}
          {{/}}
        ]
      }
    }


  • Now click on "Turn On Rule", enter below inputs and Turn on Rule:





Last modified on Sep 5, 2024

Was this helpful?

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