I hope someone can assist here. I have tried to get things working but my understanding of regex, even with the help of regex101.com is limited.
I have a process that processes a mailbox to create tasks. That part works fine, but my intention is to have an automation pick up that task and create a worklog for a user automatically. I'm not in control of the body of the email (and thus the description of the task), but it is consistent. The body of the email (or the bit I care about) looks like this:
Staff Member: Tim Foster
Department: Framework
Staff Member: Tim Foster
Leave Type: Annual Leave
From: Monday, 15-Aug-22
To: Monday, 15-Aug-22
[1] [2]
Days: 1
Working DAYS: 1
Allowance DAYS: 1
Free Days: 0
Non Working Days: 0
Leave Notes:
I have managed to get my regex to determine the name, From, To and working days, so I'm close. However, the fromdate variable that I have set, contains "Monday, 15-Aug-22" and I am struggling to convert this to a date.
My variable is set with {{issue.description.match("(?<=From\: )([^, ]+), (.*)")}}
I tried {{issue.description.match("(?<=From\: )([^, ]+), (.*)").toDate}} and I tried {{FromDate.toDate}} as a separate step, but everything I try seems to null the variable. I thought maybe I need to remove the Monday, but because this comes from an email there is another From: in the body and my regex knowledge isn't good enough to work out how to ignore the day and comma.
My ultimate aim is to have it as a date so I can add the working days to it in a loop and create a work log for each day of holiday.
I was quite proud of myself having got the values out in the first place, but now I'm stuck getting over this final hurdle.
Could someone point me in the right direction please?
Hi @Tim Foster
If you are already successfully setting the created variable with "Monday, 15-Aug-22" perhaps try splitting on the comma and then converting:
{{varMyDateVariable.split(",").last.toDate}}
or use substringAfterLast(", ") to get at the date string rather than split.
Kind regards,
Bill
Thanks Bill, this did the job. Is there a language reference I can refer to anywhere? I have struggled regularly to find a solution to a problem that turns out to be a simple language reference function. I try the community forums and often find that others have asked similar questions and been pointed toward inherent functions (often by you), but it would be great to have a fully language reference to refer to.
Incidentally, with this one, I have discovered I'm not going to be able to achieve what I wanted to do anyway since I want to add a time log for the user on holiday and the automation doesn't allow me to log time for another user (or change the actor running the automation).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tim,
Short answer: I have not found a single, complete source yet for Automation for Jira documentation.
Longer answers: When I am lookup up automation information, I usually start here for the smart values and and functions lists: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/ If you navigate up in that tree you can find the information on triggers and conditions. And when stuck trying to find the smart value for a field, this is a handy reference linked to that page: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/
The documentation seems to be improving steadily, and I have made some suggestions to make it more like the REST API info, with everything on one page: https://jira.atlassian.com/browse/JIRAAUTOSERVER-103
Disclaimer that I have not tried this for worklogs: Regarding logging time on behalf other other people, that does seem possible if you call the REST API from a web request, and supply the person's account ID value:
To find this information, I looked over the REST API documentation to find the method and checked the parameters. This use case is another example why documenting all automation behavior is a challenge: it links to a bunch of other features. :^)
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.