3. Projectrak list field from Jira groups: options edition

3. Projectrak list field from Jira groups: options edition

This article describes how to edit the Projectrak list field options automatically using an Automation rule, in case of any Jira group name where change.

 

Step 0. Get the Projectrak List field Id

First of all, get the Projectrak “List (multiple select)” field Id from the Projectrak Field manager.
In this example, the id is “433066”.

imagen-20240618-102327.png

 

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 trigger

Create a new trigger → Scheduled

  • Select the basic section

  • Choose your specific time: in this example every day at 06:00 AM

 

Step 3. Get 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.

 

Step 4. 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 5. Rule step: get the Projectrak list field options

Add component → New action → Send web request

Replace the <list_field_id> with the one obtained in step 0
Replace the <max_items> with the max number of existing groups in the Jira instance. For example: 100.

  • Web request URL: https://profields-cloud.deiser.com/items/fields/<list_field_id>?size=<max_items>

  • HTTP method: GET

  • Web request body: Empty

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

  • Headers:

    • Accept: application/json

    • Authorization: Bearer {{projectrakJwt}}

imagen-20240618-103033.png

 

Step 6. Rule step: iterate each Projectrak list field option

Add component → New branch → Advanced branching

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

  • Variable name: projectrakFieldOption

imagen-20240620-144007.png

Step 7. Rule step: get the corresponding Jira group

Add component → New action → Send web request

  • Web request URL: https://<your_instance>.atlassian.net/rest/api/3/group/bulk?groupId={{projectrakFieldOption.customId}}

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

  • Headers:

    • Accept: application/json

    • Authorization: Basic <Jira base64 authentication string>

imagen-20240718-123946.png

 

Step 8. Rule step: check valid response

Add component → New Condition → Smart values

  • First value: {{webResponse.status}}

  • Second value:  200

imagen-20240718-124151.png

 

Step 9. Rule step: store the Jira group name in a variable

Add component → New Action → Create variable

  • Variable name: jiraGroupName

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

imagen-20240718-124510.png

 

Step 10. Rule step: check if the Jira group name match with the Projectrak list field option value

Add component → New condition → {{smart values}} condition

  • First value: {{jiraGroupName}}

  • Condition: does not equal

  • Second value: {{projectrakFieldOption.value}}

imagen-20240718-124604.png

 

Step 11. Rule step: remove the Projectrak list field option

Add component → New action → Send a web request.

  • Web request URL: https://profields-cloud.deiser.com/items/{{projectrakFieldOption.id}}

  • HTTP method: PATCH

  • Web request body: Custom data

    { "id": {{projectrakFieldOption.id}}, "value": "{{jiraGroupName}}", "enabled": true, "order": {{projectrakFieldOption.order}}, "customId": "{{projectrakFieldOption.customId}}" }
  • Headers:

    • Authorization: Bearer {{projectrakJwt}}  

    • Content-type: application/json

imagen-20240718-124655.png

 

And that’s all folks!