Requisites
For the execution of this rule, there must be 3 previously created fields.
Start date: Date field
End date: Date field
Planned Duration (natural days): Number field
Configure the rule trigger
Create a new trigger → Incoming webhook
...
Set the field “Execute this automation rule with“ with “No issues from the webhook“
...
Create a Projectrak outgoing webhook
In order to the rule will be executed when a project field changed we need to create a outgoing webhook pointing to the Automation Incoming webhook url.
...
Info |
---|
Now, when a Projectrak field value is edited in any project, the Automation rule will be triggered. |
Configure the rule steps
You can see the information that will be sent to the rule every time a field is updated in a project here: Outgoing webhooks
1. Getting the project id
Create an action: Create variable
Variable name: projectId
Smart value: {{webhookData.project.id}}
...
2. Check if the start date is edited
Create an action: Create variable
Variable name: hasStartDate
Smart value: {{#webhookData.fields}}{{#if(equals(name,"Start date"))}}{{value.current}}{{/}}{{/}}
3. Check if the end date is edited
Create an action: Create variable
Variable name: hasEndDate
Smart value: {{#webhookData.fields}}{{#if(equals(name,"End date"))}}{{value.current}}{{/}}{{/}}
...
4. Check if the rule should be executed
Create an action: Create variable
Variable name: shouldExecute
Smart value: {{or(hasStartDate.isNotEmpty(),hasEndDate.isNotEmpty())}}
...
5. If the rule should be executed continue
Create a condition: Advanced compare condition
First value: {{shouldExecute}}
Condition: equals
Second value: true
...
6. Get the Projectrak authorisation JWT
Add the steps explained here: How to create a Projectrak authorization in Automation for Jira
7. Get the value of the field Start date in the project
Create an action: Send web request
Web request URL: https://profields-cloud.deiser.com/values/projects/{{projectId}}/fields/<START_DATE_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
8. Set the value in a variable
Create an action: Create variable
Variable name: startDate
Smart value: {{webResponse.body.value.value}}
9. Get the value of the field Start date in the project
Create an action: Send web request
Web request URL: https://profields-cloud.deiser.com/values/projects/{{projectId}}/fields/<END_DATE_FIELD_ID>
Headers:
Content-Type: application/json
Authorization: {{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
...
10. Set the value in a variable
Create an action: Create variable
Variable name: endDate
Smart value: {{webResponse.body.value.value}}
...
11. Calculate the planned duration days
Create an action: Create variable
Variable name: plannedDurationDays
Smart value: {{startDate.toDate("yyyy-MM-dd").diff(endDate.toDate("yyyy-MM-dd")).days}}
...
12. Set the value in the Planned Duration field
Create an action: Send web request
Web request URL: https://profields-cloud.deiser.com/values/projects/{{projectId}}/fields/<PLANNED_DURATION_FIELD_ID>
Headers:
Content-Type: application/json
Authorization: {{projectrakJwt}}
HTTP method: POST
Web request body: Custom
Custom data: {"value": "{{plannedDurationDays}}"}
Check: Delay execution of subsequent rule actions until we've received a response for this web request
...
Info |
---|
This example uses an incoming webhook trigger and two date fields to calculate the period but more options can be used. I.e. You can calculate the remaining time of a project with a scheduled trigger that executes every day and the end date of the project and the current date (see Jira smart values - date and time ) |