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.
- 1 Step 1. Create a βTeam managed spaceβ field and get the field id
- 2 Step 1. Create an Automation rule
- 3 Step 2. Rule step: configure a βSpace createdβ trigger
- 4 Step 3. Create a Jira API token
- 5 Step 4. Rule step: get space info from Jira
- 6 Step 5. Rule step: create a variable to store the space style
- 7 Step 6. Rule step: create condition for βnext-genβ spaces
- 8 Step 7. Get the Projectrak authorization token and store it in a variable
- 9 Step 8. Rule step: get the βNoβ value id, from the Projectrak βTeam managed spaceβ field
- 10 Step 9. Rule step: store the Status id in a variable
- 11 Step 10. Rule step: update space βTeam managed spaceβ field to βNoβ
Β
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
Β
Β
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.
Β
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 | base64For 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}}
Β
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
Β
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!