Projectrak as action - Identify spaces if they are Jira team managed

Projectrak as 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: How to create a Projectrak authorization in Automation for Jira

  • “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!