Document toolboxDocument toolbox

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

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

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

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

 

0. Create a “Team managed project” 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

 

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

 

2 . Rule step: configure a “Project created” trigger

Here you can choose that the rule applies to All Projects in Jira,

or to a particular type of Project in Jira like Software projects.

 

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.

 

4. Rule step: get project 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

 

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

Add component → New Action → Create variable

  • Variable name: projectStyle

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

6. Rule step: create condition for “next-gen” projects

Add component → New condition → Advanced compare condition

  • First value: {{projectStyle}}

  • Condition: does not equals

  • Second value: next-gen

 

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:

  • “6. Get the Projectrak JWT”

  • “7. Store the JWT in a variable“

 

8. Rule step: get the “No” value id, from the Projectrak “Team managed project” 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

 

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}}{{/}}

 

10. Rule step: update project “Team managed project” field to “No”

Add component → New action → Send a web request

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