Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automation : Max Due Date for an Assignee

Syed Nabeel Anwer September 30, 2024

I am looking for an automation if there is anyway for the same Assignee the Due Date is set as per the tasks max due date that are already assigned.

 

Nabeel is assigned with 2 tasks with due date:

22/9/2024

25/9/2024

 

If I assign one more task to Nabeel, that task will be 25/9/2024 + 5 business days.

 

How can we find the max due date for a specific assignee?

 

No Answer covered what was asked for so far

3 answers

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 30, 2024

Hi @Syed Nabeel Anwer 

For your scenario to access the maximum Due Date value, there are two possible approaches:

As you appear to want to use the value to edit an issue, the second approach must be used.

 

Unlike with Jira Cloud, the Lookup Issues action cannot be used for this scenario: the results contain a limited number of fields, and the Due Date is not one of them: https://jira.atlassian.com/browse/JIRAAUTOSERVER-877

 

Kind regards,
Bill

0 votes
Bandarupalli Sai
Contributor
September 30, 2024

@Syed Nabeel Anwer - Follow the below steps to create the automation rule for your requirement

Set the Trigger:

  • Select the trigger "Issue Assigned".
    • This trigger will fire when the assignee is set or changed on an issue.

Add a Condition to Check if the Assignee is Not Empty:

  • Add a new Condition:
    • Field value condition: Check that the Assignee field is not empty (Assignee != Empty).

Find the Maximum Due Date of Issues Assigned to the Same User:

  • Add a new Branch Rule / Related Issues:

    • Choose Related Issues: JQL.

    • Use the following JQL query to find all issues assigned to the same assignee that are not the current issue:

      jql
      assignee = {{issue.assignee}} AND project = {{issue.project}} AND key != {{issue.key}} AND duedate IS NOT EMPTY
  • After setting up the branch, add the following action:

    • Create Variable:
      • Variable name: maxDueDate

      • Smart value for variable :- {{issues.duedate.max}}

    This will find the maximum due date (in milliseconds) of all issues assigned to the current user in the project.

Set the Due Date of the New Issue:

  • Add a new action Edit Issue:
    • Choose Due Date as the field to update.

    • Set the Due Date using the following smart value:

      {{maxDueDate.plusBusinessDays(5)}}
    • This formula will add 5 business days to the maximum due date. Note that the formula is adding 5 days in milliseconds (5 * 24 * 60 * 60 * 1000).

    • Save and publish the rule.

Hope this helps!

 

Syed Nabeel Anwer September 30, 2024
Getting the following error

Create variable

Error rendering smart-values when executing this rule:
Unknown unary operator { at character position 1: {max(issue.duedate.asMillis)}

Edit issue

Error rendering smart-values when executing this rule:
Unknown unary operator { at character position 1: {maxDueDate} + (5 * 24 * 60 * 60 * 1000)
Syed Nabeel Anwer September 30, 2024

issue001.jpg

Syed Nabeel Anwer September 30, 2024

Even tried the changes you have applied, the due date is not populating in the assigned issue. One confirmation, edit action will be performed outside the branch.

Syed Nabeel Anwer September 30, 2024

I put the log for maxDueDate its showing all the three values in it. I think thats the issue

issue002.jpg

0 votes
Muhammad Moazzam Hassan
Contributor
September 30, 2024

Yes, it is possible.

When the ticket is assigned check if the assignee is Nabeel, then look up issues via query it will return the due date of all issues and then find the max due date via lookupmax function and edit the due date field via smart value mentioned below.

image.png

Syed Nabeel Anwer September 30, 2024

Thanks Moazzam for the response. This automation may run perfectly for the current user. But the ask here is if I assign any task to other user, in that case his/her max due date + 5 business days should be set for the task.

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 30, 2024

Hi @Muhammad Moazzam Hassan 

I believe the lookup issues action for Jira Server / Data Center does not support the due date field yet: https://jira.atlassian.com/browse/JIRAAUTOSERVER-877

Kind regards,
Bill

Muhammad Moazzam Hassan
Contributor
September 30, 2024

Hi @Syed Nabeel Anwer ,

I have added current user just for testing, please use this query 

assignee = {{issue.assignee}} and duedate is not empty ORDER by due DESC

Muhammad Moazzam Hassan
Contributor
September 30, 2024

As @Bill Sheboy highlighted the JIRA server can't return the due date via the lookup function, Please first try to print the value and see if it is returning the result or not.

You can use the log action function and print the value via smart value

{{lookupIssues.Duedate.max.plusBusinessDays(5)}}

Syed Nabeel Anwer September 30, 2024

@Muhammad Moazzam Hassan 

There is no value reflecting in the log, although its picking up the issues in the criteria but not returning the max due date 

issue003.jpg

Suggest an answer

Log in or Sign up to answer