This example describes how to create a Projectrak list field whose options will be the Jira instance groups.
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”.
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 trigger
Create a new trigger → Scheduled
Select the basic section
Choose your specific time: in this example every day at 06:00 AM
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: 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“
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}}
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}}
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.
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>
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>
8. Rule step: iterate each Jira group
Add component → New branch → Advanced branching
Smart value: {{webResponse.body.groups}}
Variable name: jiraGroup
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}}
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!