Jira Automate: Syntax for Text Manipulation

Joshua Carr December 22, 2020

Hello,

I am attempting to define an automation rule such that when a request is submitted meeting certain criteria, the ticket description will be searched for formatted text following the phrase "Due Date: ", and that text will be used to set the ticket's Due Date.

For example, imagine that the description was simply "Due Date: 2020-12-03". The question would be what Smart Text rule to define in order to set the Due Date to 12/3/2020 (within the blank under "Edit issue").

Here's what I've worked out so far, which is probably completely off-base regarding the syntax for chaining smart text functions together, but which I hope illustrates what I'm after. In my searches, I couldn't find much in the way of examples for doing this sort of thing:

{{issue.description.convertToDate(substring({{#=}}indexOf("Due Date: ")+10,{{#=}}indexOf("Due Date: ")+19))}}

1 answer

1 accepted

0 votes
Answer accepted
Joshua Carr December 23, 2020

For posterity, I figured this out. Here's what I wound up doing:

{{issue.description.substringAfter("Due Date: ").left(10)}}

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.
December 23, 2020

Hi @Joshua Carr 

How are you handling missing/invalid values following the text "Due Date: "?  Perhaps with a condition before attempting to replace the existing field value?

Best regards,

Bill

Joshua Carr December 23, 2020

I'm actually not. In this case, there's a form that feeds the field, and the form enforces DD-MM-YYYY formatting.

 

I imagine that it's possible to set things up to account for a degree of variant entry in case the date entry was free-text, but I imagine it would take a lot of work or would require use of already-developed tools. And of course typos are always possible in that case.

Like Bill Sheboy likes this
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.
December 23, 2020

Gotcha and thanks!

Joshua Carr January 25, 2021

@Bill Sheboy - As I continued work on this, I wound up needing to handle variable-length values. I did it by outputting all the non-whitespace characters between two string matches. Here's an example:
{{issue.description.substringAfter("Client Name:,").substringBefore("Account Executive:").trim()}}

Like # people like this

Suggest an answer

Log in or Sign up to answer