Forums

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

Jira Automate: Syntax for Text Manipulation

Joshua Carr
Contributor
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
Contributor
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
Contributor
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
Contributor
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 2 people like this

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, mindful member, mindful member badge, atlassian community, community kudos, community giveaway, atlassian swag, community values, empathy and kindness, badge challenge, atlassian learning, community engagement, swag giveaway

Earn a Badge, Win a Prize 🎁

Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!

Start here
AUG Leaders

Atlassian Community Events