Document toolboxDocument toolbox

Projectrak as action - Bulk change a project field value

This example demonstrates how to update the value of a Projectrak status field in multiple projects within your instance using manually triggered Automation.

1. Obtain the field IDs for the Projectrak Status and Projectrak Key fields.

First of all, It’s necessary to obtain the Projectrak “Status” from the Projectrak Field manager.

In the following example, the IDs are 12 for status and 2 for key.



2. Create an Automation rule

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

 

3. Rule steps: configure a trigger

Create a new trigger → “Manual trigger from issue”

4. Rule steps: 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 https://deiser-apps.atlassian.net/wiki/spaces/PROJECTRAKCLOUD/pages/1641490/How+to+create+a+Projectrak+authorization+in+Automation+for+Jira?src=search:

  • “6. Get the Projectrak JWT”

  • “7. Store the JWT in a variable“

 

5. Rule step: get the “Off track” value id, from the Projectrak Status field

Add component → New action → Send web request

Replace the <status_field_id> with the one obtained in step 1

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

  • 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

 

6. Rule step: store the Status id in a variable

Add component → New Action → Create variable

  • Variable name: projectrakOfftrackStatusId

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

 

7. Generate a base64 authentication string for Jira

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.

Open a Linux terminal and execute this command:

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

Copy the result string, please.

 

8. Rule step: get all projects through Jira API.

Add component → New action → Send web request

  • Web request URL: https://deiserdemo.atlassian.net/rest/api/3/project

  • Headers:

    • Authorization: Basic {{base64 authentication string for Jira}}

  • 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: iterate each project

Add component → New branch → Advanced branching

  • Smart value: {{webResponse.body}}

  • Variable name: project

10. Rule step: get the Projectrak project key field in each project

Into the “For each”: Add component → New action → Send web request

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

  • 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

  • Check: Continue running the rule even if the request response is not successful (i.e. non-200 response)

11. Rule steps: compare if the obtained project keys meet the condition.

Into the “For each”: Add component → New condition → Advanced compare condition

  • First value: {{webResponse.body.value.value}}

  • Condition:  contains regular expression

  • Second value: (<project_key_01>|<project_key_02| … )

    • Here, we check if the keys are valid to modify the value status. If the project key is in the “second value” of the condition, we will change the value.

 

12. Rule step: update project status field to “Off track”

Into the “For each”: Add component → New action → Send a web request

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

  • Headers:

    • Content-Type: application/json

    • Authorization: Bearer {{projectrakJwt}}  

  • HTTP method: POST

  • Web request body: Custom data

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

{ "value": {{projectrakOfftrackStatusId}} }
  • Check: Delay execution of subsequent rule actions until we've received a response for this web request

  • Check: Continue running the rule even if the request response is not successful (i.e. non-200 response)