Action - πŸ” Identify spaces if they are Jira team managed

Action - πŸ” Identify spaces if they are Jira team managed

This example describes the automatic categorization of spaces when they are created, in this case we take into account if they are β€œTeam managed” or β€œCompany managed” by field of β€œTeam Managed” spaces when are created by user.

Our objective is to control if the space is team managed and to classify and filter our spaces by this Jira option.

Β 

Here you can see where we reference to classify the space.

Create space.svg

Β 

Step 1. Create a β€œTeam managed space” field and get the field id

First of all, it's necessary to create a Single select field, we have called β€œTeam Managedβ€œ with just one option called β€œNo”.

Then, get the field id of the field from the Projectrak field manager. In this example, the field id is: 253710

Team Managed.svg

Β 

Β 

Step 1. Create an Automation rule

Go to: Settings \ System \ Global Automation, and create a new rule.

You can also go there with a direct link, just replacing <your_instance> with yours:
https://<your_instance>.atlassian.net/jira/settings/automation

Β 

Step 2. Rule step: configure a β€œSpace created” trigger

Here you can choose that the rule applies to All Spaces in Jira, or to a particular type of Space in Jira like Software spaces.

Space created.svg

Β 

Step 3. Create a Jira API token

If you don’t have a Jira API token yet, please go to this page and generate it:
If you have already one, you can reuse it.

Once created the Jira API token, open a Linux terminal and execute this command to generate a base64 authentication string:

echo -n JIRA_USER_EMAIL:JIRA_API_TOKEN | base64
  • For Windows powershell, please refer this link.

Copy the result string for the next step, please.

Β 

Step 4. Rule step: get space info from Jira

Add componentΒ β†’ New actionΒ β†’ Send web request

  • Web request URL:Β https://<your_instance>.atlassian.net/rest/api/3/project/{{project.id}}

  • Headers:

    • Content-Type: application/json

    • Authorization: BasicΒ <Jira base64 authentication string>

  • HTTP method: GET

  • Web request body: Empty

  • Check:Β Delay execution of subsequent rule actions until we've received a response for this web request

Β 

Step 5. Rule step: create a variable to store the space style

Add componentΒ β†’ New ActionΒ β†’ Create variable

  • Variable name: spaceStyle

  • Smart value:Β Β {{webResponse.body.style}}

SpaceStyle.svg

Β 

Step 6. Rule step: create condition for β€œnext-gen” spaces

Add componentΒ β†’ New condition β†’Β Advanced compare condition

  • First value:Β {{spaceStyle}}

  • Condition: does not equals

  • Second value: next-gen

SpaceStyle conditional.svg

Β 

Step 7. Get the Projectrak authorization token and store it in a variable

If you don’t have a Projectrak API token yet, follow the first steps (1 to 5) of the link below.
If you have already got it, you can reuse it.

Add to the rule the last 2 steps described in this link: Setup - βš™οΈ Create a Projectrak authorization

  • β€œ6. Get the Projectrak JWT”

  • β€œ7. Store the JWT in a variableβ€œ

Β 

Step 8. Rule step: get the β€œNo” value id, from the Projectrak β€œTeam managed space” field

Add componentΒ β†’ New actionΒ β†’ Send web request

Replace the <select_field_id> with the one obtained in step 0

  • Web request URL: https://profields-cloud.deiser.com/items/fields/<select_field_id>?query=No

  • Headers:

    • Content-Type: application/json

    • Authorization: Bearer {{projectrakJwt}}

  • HTTP method: GET

  • Web request body: Empty

  • Check:Β Delay execution of subsequent rule actions until we've received a response for this web request

Β 

Step 9. Rule step: store the Status id in a variable

Add componentΒ β†’ New ActionΒ β†’ Create variable

  • Variable name: projectrakNoTeamManagedId

  • Smart value:Β Β {{#webResponse.body.values}}{{id}}{{/}}

Β 

Step 10. Rule step: update space β€œTeam managed space” field to β€œNo”

Add componentΒ β†’ New actionΒ β†’ Send a web request

Replace the <select_field_id> with the one obtained in step 0.

  • Web request URL:Β https://profields-cloud.deiser.com/values/projects/{{project.id}}/fields/<select_field_id>

  • Headers:

    • Content-Type: application/json

    • Authorization: Bearer {{projectrakJwt}}Β Β 

  • HTTP method: POST

  • Web request body: Custom data

  • Custom data: {{projectrakNoTeamManagedId}} is the item ID of status field from Projectrak

{ "value": {{projectrakNoTeamManagedId}} }

Β 

And that’s all folks!