Hi Everyone, I am on Jira Data Center 9.12.17 with JSM.
I have assets that have a License End Date attribute. I have setup automation to send emails when they are about to expire. What is sent in the email is the following:
Name: Knowbe4
Description: `Knowbe4 Security Awareness training
License Start Date: 1712016000000
License End Date: 1743566400000
The dates are in the wrong format even though they show correctly in Assets:
Here what my automation looks like:
I have tried different smart values formatting like {{attributes.License End Date2.jiraDate}} or
{{attributes.License End Date2.format("mm/dd/yyyy")}} and nothing seems to work.
Any help is appreciated!
This is what worked for me after consulting with Atlassian support:
I had to create a personal authentication token and then use that in the automation rule:
Let me know if you need more info.
Hello Patricia,
The issue here is that the License Start Date and License End Date values are being displayed as Unix timestamps. The reason {{attributes.License End Date2.format("mm/dd/yyyy")}} did not work correctly is due to Incorrect Format Specifier for Month. mm Represents minutes, not months.
Try this solution:
License Start Date: {{attributes.License Start Date.format("EEEE, MMMM dd, yyyy")}}
License End Date: {{attributes.License End Date2.format("EEEE, MMMM dd, yyyy")}}
Expected Output:
License Start Date: Tuesday, April 02, 2024
License End Date: Thursday, May 02, 2025
If you want the date format as 07/06/2025 (MM/dd/yyyy), use:
{{attributes.License End Date.format("MM/dd/yyyy")}}
Let me how it goes.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for the response @Emmanuel Abwao. Unfortunately that did not work. Here is what I am seeing in the email:
The following software license is due to expire soon:
Name: Knowbe4
Description: `Knowbe4 Security Awareness training
License Start Date: 1712016000000
License End Date: MM/dd/yyyy1743552000000
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Patricia. If it is possible, you may attach the image of the attribute and the smart values you've inserted. The syntax might be a problem. Let me know as soon as you do.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is my code:
I have tried this:
{{#lookupAssets}}
Name: {{attributes.Name}}
Description: {{attributes.Description}}
License Start Date: {{attributes.License Start Date}}
License End Date: {{attributes.License End Date.toDate("MM/dd/yyyy")}}
{{/}}
And here is the other one you told me to try:
{{#lookupAssets}}
Name: {{attributes.Name}}
Description: {{attributes.Description}}
License Start Date: {{attributes.License Start Date}}
License End Date: {{attributes.License End Date.format("MM/dd/yyyy")}}
{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The answer has been marked as accepted. What is the solution that actually works? The suggestion to use the format command doesn't work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Trudy Claspill I unmarked the answer as unaccepted. I had to talk to Atlassian support in order to get it to work correctly. We ended up using /rest api in order to get the data and then convert it from there. If you need those steps let me know and I can add them here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Patricia Molina
Please do add them. If you add them using the "Suggest an answer" entry at the bottom of the replies then you can mark your own answer as Accepted.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh man, yeah, so as @Emmanuel Abwao pointed out, Assets stores dates as Unix timestamps (also known as epoch time) and despite the optimism of @Shawn Doyle - ReleaseTEAM back in July that Atlassian would eventually get around to "Atlassianize"-ing Assets codebase to behave like other date fields, that doesn't seem to have happened yet.
Anyways, Unix time is defined by Wikipedia thusly:
It measures time by the number of non-leap seconds that have elapsed since 00:00:00 UTC on 1 January 1970, the Unix epoch. For example, at midnight on 1 January 2010, Unix time was 1262304000.
SO ANYWAYS, way back in 2021, @Italo _Modus Create_ came up with the solution here that I'm adapting:
So yeah, Italo's brilliant solution was to convert the Epoch (01/01/1970) to a date object using the toDate function, and THEN use plusMillis to add your asset's timestamp (which is millliseconds since Epoch, not seconds). Finally we use format to get MM/dd/yyyy that you want.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found a similar solution from @Bill Sheboy here.
The asNumber function is not support in Automation on Jira Data Center.
While {{lookupAsset.attributes."Name of Date attribute"}} yields a value like
1743984000000
{{lookupAsset.attributes."Name of Date attribute".asNumber}} yields no data.
I also looked at stuffing the value into a Number field (Story Points) in the issue, but in my case that cannot be done because it caused an error in the database trying to convert a Float to a Numeric.
But I found that I could store this number: 1743984000 (the original number divided by 1000 to get Seconds)
I could then use it thus:
{{now.toStartOfDay.withYear(1970).withDayOfYear(1).plusSeconds(issue."Number field")}}
Unfortunately I have not yet figured out how to convert the asset date to a number that can be added to the field.
{{#=}} {{lookupAsset.attributes."Name of Date Attribute"}} / 1000 {{/}}
...yielded the right number - 1743984000.
But when I tried to use the math function to set the Number Field in the issue, the field did not get set and no error was reported.
I also tried creating a variable set to the above math function and then setting the issue Number Field to the variable, but that circles back to not being able to use a string when a number is expected.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A couple of things to try...
#1) Where you copied the number and got the float conversion error, try adding floor to force the value to an integer first.
#2) Try using the longer format of date math expressions, which works for Cloud but I do not know if it works for Server / Data Center. The idea is to first create a variable for the start-of-epoch-time, and then add your number of seconds, wrapped in a math expression.
For example:
For some reason, this cannot all be done in one step with Cloud, but please experiment to learn if it works and can be condensed for Server / Data Center.
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.
Thank you for the feedback @Bill Sheboy
#1) Where you copied the number and got the float conversion error, try adding floor to force the value to an integer first.
That was in the Edit Issue screen in the UI.
#2
I tried this originally from your solution:
{{now.withYear(1970).withDayOfYear(1).toDateTimeAtStartOfDay}}
It yielded no value. The components worked until I added .toDateTimeAtStartOfDay
Subsequently I found that this worked instead:
{{now.toStartOfDay.withYear(1970).withDayOfYear(1)}}
Otherwise I tested your solution and it appears to work!! I'm going to do more testing to make sure.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great answer @Emmanuel Abwao . Do you happen to have a link for that?
I'd like to learn what else I can customize. Thank you,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Rodney,
For the customization of dates, use the java date pattern syntax. Here is an example:
Data and Time Format
To use them in relation to Atlassian's smart values like in assets above, you may want to read this:
Automation smart values - date and time | Cloud automation Cloud | Atlassian Support
I hope that helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.