Forums

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

How to handle automation actions when the data is a date within a text field.

David Quiram
Contributor
September 19, 2024 edited

In our IdP (Okta) we have a custom text field to facilitate a specific date for people. I will be syncing this field over to a custom read-only text field in Atlassian, via MindPro Sync, so that it will be available on issues and for Automation. 

I would like to setup an automation where an issue is auto-closed with comment based on that "date". If it were a true date field, I could use a smart value time comparison, but since it's a text field, I feel that wont be possible via the exact same means. 

Due to the systems in place, we are locked into use text fields for this. 

Does anyone have suggestions on this? Thank you for your time and consideration. 

3 answers

1 accepted

2 votes
Answer accepted
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 20, 2024

Hello @David Quiram 

There are functions that can be applied to smart values in automation to convert text to dates that can then be used in date-applicable functions.

@Bill Sheboy provided an answer to a similar question on this post and this post referencing the toDate function.

David Quiram
Contributor
September 20, 2024

Amazing! Thank you so much. I'll def be digging into those posts next week! 

Like • Trudy Claspill likes this
0 votes
David Quiram
Contributor
October 1, 2024

So, for anyone coming here looking for more information. Trudy's answer is the accepted answer as it helped point to good sources of information. I did need to reach out to support to help provide more context as I just couldn't get the formatting correct. 

This is how my brain rationalized the format: 

{{field_with_string.toDate("Format of Data").extraFunctions.displayFormat}}

So source data of "03 26 1990" put through this:

{{issue.customfield_10385.toDate("MM dd YYYY").shortDate = 3/26/90
{{issue.customfield_10385.toDate("MM dd YYYY").plusMonths(1).shortDate = 4/26/90

0 votes
David Quiram
Contributor
September 23, 2024

So... I have been picking away at this for a few hours now trying different combinations to see if I could land on the solution and it's not quite catching. What am I missing?

My Okta variable has the value of March 26, 1990. I have tried this as both:
1990-03-26
1990 03 26

In the automation, I store the data into a variable {{TestVariable}} and I give it the smart value of:
{{issue.customfield_10385.toDate("yyyy-MM-dd")}}
{{issue.customfield_10385.toDate("yyyy MM dd")}}
{{issue.customfield_10385.toDate(jiraDate)}}

I then log the action so I can visually inspect what is being used. I log both the variable and the smart value for comparison and for all three variants that I have tried we get: 
1990-03-26T00:00:00.0+0000

If I am reading documentation correctly, it is putting the time value in there because that is the default format for a date/time value. So, am I doing something incorrectly with my smart value? 

Moving on, the next thing I tried to log was adjusting the date/time value by doing a plus 1 month to it. I tried the following and both display no data, but don't error:
{{issue.customfield_10385.toDate("yyyy-MM-dd").plusMonth(1)}}
{{TestVariable.plusMonth(1)}}

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
atlassian, atlassian community, journeys for jira service management, journeys for jsm, eap jsm atlassian, early access program atlassian, early access program journeys atlassian, early access program journeys jira service management, join atlassian eap

Join the Early Access Program (EAP) - Journeys for Jira Service Management 🚪

Journeys is a brand new feature in Jira Service Management that helps you streamline various processes in your organization that may cross multiple departments, such as employee onboarding or off-boarding that require action from different teams. ✨

Join the EAP →
AUG Leaders

Atlassian Community Events