Automation creation for "Project Start/ Target" custom date fields for -#days

Sahar Qarem July 10, 2024

Hello,

Need to create a jira automation to send a scheduled email of all the ideas that have a project target in set number of days, but since it's not a jira field I'm only able to search for a specific date not if "x number of days left.

Any idea how?

4 answers

1 accepted

1 vote
Answer accepted
Nick Haller
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 10, 2024

Hi  @Sahar Qarem .

Important to note Jira dates follow a specific date (and time) formatting like:

"YYYY-MM-DD"

JPD dates follow a range formatting like:

"{\"start\":\"YYYY-MM-DD\",\"end\":\"YYYY-MM-DD\"}"

Because of the difference - JPD date-fields are not fully supported with automations, and also do not have the same filtering / JQL capabilities like Jira date-fields.

Having said that, I think your use case may still be possible if we manipulate the JPD date-field through smart values, and compare it to a date or another field. Below is an example of this.

targetdate1.jpeg

 

1) WHEN: Scheduled (select when this automation should be scheduled to run)

2) THEN: Create variable

  • Variable name = TargetDate (or anything you like)
  • Smart value = 
{{issue.customfield_XXXXX.substringBetween("\"start\":\"","\",\"end\"")}}
  • ^ customfield_XXXXX would be the custom ID of your JPD date-field

*3 / 4) These steps can be disregarded, and were simply used for logging purposes to troubleshoot and debug throughout testing

5) IF: {{smart values}} condition (aka "Compare two values")

  • First value = {{TargetDate}}
    • ^ This would be the variable configured in step 2
  • Condition = equals
  • Second value = {{now.plusDays(5).jiraDate}}

6) THEN: Send Slack message (or email user(s) / preform some other action)

 

Step 2 converts my JPD Project target field from a range, into a variable with the formatting of yyyy-mm-dd. This is done using string processing.

Step 5 then compares the variable to the present date + 5 days from now (future date so to speak), and if these two dates match - the automation sends a message to Slack.

Here is the Audit log tab of this automation through some testing:

targetdate2.jpeg

 

I'm not sure this is the "perfect" way to do this, but I hope it helps and can reference when configuring your automation!

Sahar Qarem July 11, 2024

Hi Nick, 

I've tried it, and it's not working. I've used the log and it shows as attached. 

maybe the smart value format is missing something?

{{issue.customfield_10152.substringBetween("\"start\":\"","\",\"end\"")}}

 

Screenshot 2024-07-11 at 17.41.45.pngScreenshot 2024-07-11 at 17.38.24.png 

 

ALAA EDDINE ROUCADI July 11, 2024

Hi @Sahar Qarem ,

It would be very helpful if you could post the log action result of the custom field "{{issue.customfield_10152}}". This will allow us to see the value structure. The next step would be to process this value using automation smart values to extract the information you need.

Regards,

Sahar Qarem July 11, 2024

Hi Alaa,

I've logged it and getting the same and Project Target above, (no result, empty)

I've executed the JQL below:

Project=XM AND "project target"~"2024-07-12" ORDER BY cf[10152] DESC, Created DESC

Where, "Project Target" is the custom field used in "order by" as well.

How can i search JQL using smart values? 

ALAA EDDINE ROUCADI July 11, 2024

Hi @Sahar Qarem ,

One thing to verify is the Scheduled trigger of your automation. You need to use a JQL search to define the set of issues that the rest of the automation will run on by checking "Run a JQL search and execute actions for each issue in the query".

This could be a JQL search that filters and returns only the issues corresponding to all the ideas that have a project target. You can validate the search query without running the automation, check how many issues are returned, and even click on the link to display the search results.

 

Regards,

Sahar Qarem July 11, 2024

Hi @ALAA EDDINE ROUCADI ,

I've executed the JQL below:

Project=XM AND "project target"~"2024-07-12" ORDER BY cf[10152] DESC, Created DESC

Where, "Project Target" is the custom field used in "order by" as well.

How can i search JQL using smart values? 

ALAA EDDINE ROUCADI July 11, 2024

Hi @Sahar Qarem ,

Unfortunately, as far as I know, in JPD context, the project start/target date is a relatively new and complex structure that is not supported by JQL (including using smart values)

One approach could be to filter, at the Scheduled trigger level, for ideas with a target date using a query like:

Project=XM AND 'project target' is not empty ORDER BY cf[10152] DESC, Created DESC.

Then, follow the steps described by @Nick Haller HERE. For each returned issue, the automation will:

  1. Extract the target date from your custom field. Example of LOG expression 
    Start date: {{issue.customfield_10152.match("start\":\"([0-9-]+)\"").first}}, End date: {{issue.customfield_10152.match("end\":\"([0-9-]+)\"").first}}
  2. Run it through a smart values comparison,
  3. Send the notification if the condition is met.

PS:There will be one notification sent per issue fulfilling the condition.

Sahar Qarem July 12, 2024

Hi @ALAA EDDINE ROUCADI ,

The log expression is still coming back empty for some reason, but adding the JQL query the at the "scheduled" trigger worked and the rule is executing correctly now.

Thank you!  

Like ALAA EDDINE ROUCADI likes this
0 votes
Nick Haller
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 23, 2024

Hi Community,

We were able to get this resolved through a support ticket using an automation like the one below - which can send a daily email of all ideas if their JPD date-field matches the present day:

sched1.jpeg

1) WHEN: Select schedule for automation to run

2) THEN: Lookup issues - JQL:

project = XYZ AND cf[00000] ~ "\"end\":\"{{now.jiraDate}}\""

 ^ cf[00000] is the JPD date-field's ID. Can find this using this doc: 

3) AND THEN: Send email - which uses the Lookup issues from previous step to list all ideas in email body using this:

{{#lookupIssues}}
* {{key}}, {{summary}} - {{url}}
{{/}}
0 votes
Sahar Qarem July 11, 2024

deleted

0 votes
Nick Haller
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 10, 2024

Hi @Sahar Qarem ,

Important to note Jira dates follow a specific date (and time) formatting like:

"YYYY-MM-DD"

JPD dates follow a range formatting like:

"{\"start\":\"YYYY-MM-DD\",\"end\":\"YYYY-MM-DD\"}"

Because of the difference - JPD date-fields are not fully supported with automations, and also do not have the same filtering / JQL capabilities like Jira date-fields.

 

Having said that, I think your use case may still be possible if we manipulate the JPD date-field through smart values, and compare it to a date or another field. Below is an example of this.

targetdate1.jpeg

1) WHEN: Scheduled (select when this automation should be scheduled to run)

2) THEN: Create variable

  • Variable name = TargetDate (or anything you like)
  • Smart value = 
{{issue.customfield_XXXXX.substringBetween("\"start\":\"","\",\"end\"")}}
  • ^ customfield_XXXXX would be the custom ID of your JPD date-field

*3 / 4) These steps can be disregarded, and were simply used for logging purposes to troubleshoot and debug throughout testing

5) IF: {{smart values}} condition (aka "Compare two values")

  • First value = {{TargetDate}}
    • ^ This would be the variable configured in step 2
  • Condition = equals
  • Second value = {{now.plusDays(5).jiraDate}}

6) THEN: Send Slack message (or email user(s) / preform some other action)

 

Step 2 converts my JPD Project target field from a range, into a variable with the formatting of yyyy-mm-dd. This is done using string processing.

Step 5 then compares the variable to the present date + 5 days from now (future date so to speak), and if these two dates match - the automation sends a message to Slack.

Here is the Audit log tab of this automation through some testing:

targetdate2.jpeg

 

I'm not sure this is the "perfect" way to do this, but I hope it helps and can reference when configuring your automation!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events