Automation Rule to add due date to issue from text date in description

Marc Littlefair
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 11, 2022

We have tickets coming through to our Jira Service Management from another system that sends us a date value in plain text. I'd like to create an automation to scrape that value and set the due date of the ticket to that date.

So far in my automation I've created a variable called StartDate with the smart value of {{issue.description.match("Start Date:\s(.*)")}}.

In the description of the ticket I have 

Start Date: 08/11/2022

For the purpose of debugging I have the automation add an internal comment to display the Smart Value which displays as 08/11/2022 which is correct but doesn't work when I try to update the Due Date to that.

In order to get that into the due date field I'm aware that I need to convert that Smart Value into an actual date that Jira understands but that is where I've got myself stuck, having tried to follow through instructions on https://confluence.atlassian.com/automation/working-with-dates-993924630.html to convert the text to a date the value is always blank and I don't know what I'm doing wrong.

Any help / guidance greatly appreciated!!

1 answer

0 votes
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 11, 2022

Hi Marc - Welcome to the Atlassian Community!

I would probably try to stick the value into a single line text field instead of comments since those can be one to many and harder to deal with. Then the text convert might (hopefully) will be easier.

Can you try that and see what it does? You can just use the Summary field as a test if you want. And this code then for the date field update: 

{{issue.summary.toDate("yyyy MM dd")}}

Or whatever your format for dates is. 

And if that doesn't work, can you share your rule along with the audit log so we can see any error messages? 

Marc Littlefair
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 19, 2022

Hi John, Thanks for the welcome!

Just found the time to get back to this. Thanks for you answer and apologies I didn't explain clearly that the comment is just for debugging to see what value has been scraped by the variables I've created.


The automation goes like this: First part is a variable to scrape the date out of the description.  Screenshot 2022-08-19 at 12.10.13.png

This bit works fine and I do get exactly what I am expecting.

The next part of the automation creates another variable which I was hoping would be the date in a converted form, however, this value doesn't ever generate and the audit log doesn't show any error.

Screenshot 2022-08-19 at 12.16.42.png

What I was wanting to do next is to take the newJoinerStartDate value created in the step above and edit the Due Date of the ticket.

Screenshot 2022-08-19 at 13.04.04.png

This doesn't work as the value for newJoinerStartDate is blank.  

The final part of the automation and the element that will be removed is to update the ticket with a comment showing me what values were created for each of the variables.

Screenshot 2022-08-19 at 13.06.11.pngThis updates my ticket to show this:

Screenshot 2022-08-19 at 13.06.56.pngThe initial value that is scraped from the ticket description is there and is correct, the problem seems to be when I try to convert that into a valid date format that the Due Date field will accept, sadly the audit log for this shows no errors which doesn't help direct me anywhere. 

Screenshot 2022-08-19 at 13.08.57.png

 

Any ideas / suggestions would be ace!

Allan N
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 9, 2023

No ideas or suggestions, sorry - came here to say I am stuck at this point too.

Have tried multiple date formats using .toDate, .format, .jiraDate - none of which seem to work unfortunately!

Like Kasper Ramstafer likes this
Kasper Ramstafer January 16, 2024

Same! I'm hoping to follow this thread and maybe someone will have  solution.  I've tried those same date formats to no success.

Drew Bradford June 12, 2024

I am having the same problem. I'm new to this level of automation and it seems like setting dates should be easier (looking at you Atlassian).

I'm not good enough to do this but is there a way to brute force it by using a series of Left, Right, and Replace functions to move the numbers into the yyyy-MM-dd format and convert the /'s to -'s?

UPDATE: I take it back maybe I am good enough...

Do to this is not easy and I'm sure there's someone out there who can clean this up and streamline it but here goes...

First create a variable, call it TestDueDate for this example

The Smart Value field finds the Due Date in the description:

{{issue.Description.match("[\n\r].*Test Due Date:\s*([^\n\r]*)")}}

FYI, The TestDueDate is in the format d/m/yy

 

Then pull the year (always 2 digits) with another Create Variable

Name: TestDueDateShortYear

Smart value: {{TestDueDate.right(2)}}

 

Then make the year a 4 digit year with another variable:

Name: TestDueDateLongYear

Smart value: {{TestDueDateShortYear.leftPad(4,"20")}}

 

Then find the month which is before the first "/" and set it to another variable

Name: TestDueDateMonth

Smart value: {{TestDueDate.substringBefore("/")}}

 

Convert the Month to the right two digit format so Add a Branch For: Current Issue to test if it's one digit or two:

If

{{TestDueDateMonth}} > 9

Create another Variable:

Name: TestDueDateMonthDash

Smart value: {{RFPDueDateMonth.leftPad(3,"-")}}

Add the dash "-" so it will fit the format when it is all put together.

 

Copy the branch but change it to look for months <10

Change the variable creation Smart value:

{{RFPDueDateMonth.leftPad(3,"-0")}}

Adds a 0 to months with a single digit

 

Do the same thing for the day as with month but to find the day...

Smart value: {{TestDueDate.substringBetween("/","/")}}

Use the same branches and update the variables to use day instead of month.

 

Create a variable for the Due Date that Jira can read:

Name: {{JiraTestDueDate}}

Smart value: {{TestDueDateLongYear}}{{TestDueDateMonthDash}}{{TestDueDateDayDash}}

 

Lastly, Edit the issue field Due Date

Due date:

{{JiraRFPDueDate}}

 

There are likely many extraneous steps and several steps that can be combined. This is my kindergarden version but the most important thing is that it WORKS. The due date is set correctly.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events