Hi everyone,
I’m attempting to conditionally create a dynamic label based on the value in a date field. Specifically, I’m parsing out the month to map it to a quarter. However, I can’t seem to get the equals function to resolve to true. It either resolves to false or throws an error and fails to resolve at all.
Right now I'm just writing log actions while I'm trying to get it to work.
In my testing, I’m using a September date. So, I should be able to compare it to some form of the number 9 and get it to resolve to true, but I can’t get it to work. Here are the permutations I’ve tried:
Log action = "Target Start Month: {{issue.fields.Target Start.substring(5,7)}}, Year: {{issue.fields.Target Start.substring(0,4)}}"
Log - "Target Start Month: 09, Year: 2024"
Log action = "Target Start Month: {{issue.fields.Target Start.substring(5,7).asNumber}}, Year: {{issue.fields.Target Start.substring(0,4)}}"
Log - "Target Start Month: 9, Year: 2024"
Resolves as FALSE
Resolves as: {{issue.fields.Target Start.substring(5,7).equals(09)}}
Resolves as: {{equals(issue.fields.Target Start.substring(5,7), 09)}}
Resolves as: {{equals(issue.fields.Target Start.substring(5,7).asNumber, 9)}}
Resolves as: {{equals(issue.fields.Target Start.substring(5,7).asNumber, 09)}}
Resolves as: {{equals(issue.fields.Target Start.substring(5,7).asNumber, '9')}}
FAILS to Resolve
Resolves as: {{issue.fields.Target Start.substring(5,7).equals('09')}}
Resolves as: {{equals(issue.fields.Target Start.substring(5,7), '09')}}
Resolves as: {{equals(issue.fields.Target Start.substring(5,7).asNumber, '09')}}
Any insights or suggestions on how to get this to work would be greatly appreciated!
Thanks in advance!
Hello @Denny Ransom
Welcome to the Atlassian community.
Rather than using all that Substring stuff you could use this to extract the numeric Month value from the date field
{{issue.Target Start.format("M")}}
Referring to the format command described here:
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/#Date-format---
... and the linked page for Java Documentation of additional format options:
https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
Hi @Trudy Claspill
Thanks for the suggestion.
Jira likes that even less. It doesn't even resolve to a 9 in the log. This is actually why I ended up going the substring route.
Log action = "Target Start Month format M: {{issue.fields.Target Start.format("M")}}, Year: {{issue.fields.Target Start.substring(0,4)}}"
Log - "Target Start Month format M: , Year: 2024"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Denny,
1. What is the field type of Target Start? Is it a Date picker, or Date/Time picker?
2. Remove .fields from the smart value. It isn't necessary.
3. Add a Log action to just print {{issue.Target Start}} to confirm that a) you have the correct field name and b) It actually has a value.
I tested with a Date picker field and it correctly extracted the Month value as a number.
Can you provide a screen image of the actual Log action? Perhaps there is a typo in it?
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.