1. Projectrak list field from Jira groups: options creation
This article describes how to create a Projectrak list field whose options will be the Jira instance groups using an Automation rule.
- 1 Step 0. Create the Projectrak List field
- 2 Step 1. Create an Automation rule
- 3 Step 2 . Rule step: configure a trigger
- 4 Step 3. Rule steps: get the Projectrak authorization token and store it in a variable
- 5 Step 4. Rule step: get the Projectrak list field options
- 6 Step 5. Rule step: store the list field option custom ids in a variable
- 7 Step 6. Rule step: generate a base64 authentication string for Jira
- 8 Step 7. Rule step: get all Jira groups
- 9 Step 8. Rule step: iterate each Jira group
- 10 Step 9. Rule step: check if the Jira group is already in the Projectrak list field options
- 11 Step 10. Rule step: create a new option in the Projectrak list field
Step 0. Create the Projectrak List field
First of all, it's necessary to create the Projectrak “List (multiple select)” field from the Projectrak Field manager.
Set the “Set value ID different than name“ option and enter a sample option but disabled.
In this example, the id is “433066”.
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. 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: How to create a Projectrak authorization in Automation for Jira
“6. Get the Projectrak JWT”
“7. Store the JWT in a variable“
Step 4. 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:
Content-Type: application/json
Authorization: Bearer {{projectrakJwt}}
Step 5. Rule step: store the list field option custom ids in a variable
Add component → New Action → Create variable
Variable name: projectrakFieldOptionCustomIds
Smart value: {{webResponse.body.values.customId.asJsonStringArray}}
Step 6. Rule step: 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.
Step 7. Rule step: get all Jira groups
Add component → New action → Send web request
Replace the <max_results> with the max number of existing groups in the Jira instance. For example: 100.
Web request URL: https://<your_instance>.atlassian.net/rest/api/3/groups/picker?maxResults=<max_results>
Please, check all Jira groups are returned by pasting this URL in a browser tab. In case, there’re more groups than max results, increase this limit. You can refer to the Atlassian reference here.
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:
Content-Type: application/json
Authorization: Basic <Jira base64 authentication string>
Step 8. Rule step: iterate each Jira group
Add component → New branch → Advanced branching
Smart value: {{webResponse.body.groups}}
Variable name: jiraGroup
Step 9. Rule step: check if the Jira group is already in the Projectrak list field options
Add component → New condition → Advanced compare condition
First value: {{projectrakFieldOptionCustomIds}}
Condition: does not contains
Second value: {{jiraGroup.groupId}}
Step 10. Rule step: create a new option in the Projectrak list field
Add component → New action → Send a web request
Replace the <list_field_id> with the one obtained in step 0.
Web request URL: https://profields-cloud.deiser.com/items/fields/<status_field_id>
HTTP method: POST
Web request body: Custom data
Custom data: {{projectrakOfftrackStatusId}} is the item ID of status field from Projectrak
{
"value": "{{jiraGroup.name}}",
"enabled": true,
"customId": "{{jiraGroup.groupId}}"
}Headers:
Content-Type: application/json
Authorization: Bearer {{projectrakJwt}}
And that’s all folks!