Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hi !
I want to autocomplete a date customfield with the today's date during a screen transition if it's empty.
I wrote this script in a behavior which select field and transition :
def champDateLivre = getFieldById( "customfield_10400" )
def dateDuJour = new Date()
dateDuJour = dateDuJour.format( "d/MMM/yy" )
def valeurInitiale = getFieldById( "customfield_10400" ).value
if ( valeurInitiale == "" )
{ champDateLivre.setFormValue(dateDuJour)
}
I get the date in the customfield BUT when I validate the transition I get error message : "Format de date non valide. Veuillez saisir la date au format 'd/MMM/yy'"
= Invalide date format. Please use format dat 'd/MMM/yy'
Is that one iI use and I verified configuration jira.date.picker.java.format : is the same...
Can someone help me ?
Thanks
Hi
Have you tried to enable log and check if your dateDuJour variable has required format?
Something like this:
import org.apache.log4j.Category
...
log.setLevel(org.apache.log4j.Level.INFO)
log.info("start info logging");
log.info(dateDuJour);
Thanks for your answer but I don't know how does it work...
Sry I'm not a developper
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Put in your code these rows, then run your postfunction and check log to see result
import org.apache.log4j.Category
log.setLevel(org.apache.log4j.Level.INFO)
log.info("start info logging");
log.info(dateDuJour);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried but it's not a postfunction...
I'm in behavior, in field that I want, in "server-side script"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is a example with logging I have performed. Using similar code you can check all your variables from logs
1. enabke logging for behavior
2. Create behavior with server-side script
3. check atlassian-jira.log for entries
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I got logs :
2019-06-20 09:07:31,489 [...] /rest/scriptrunner/behaviours/latest/runvalidator.json [c.o.j.groovy.user.FieldBehaviours] start info logging
2019-06-20 09:07:31,489 [...] /rest/scriptrunner/behaviours/latest/runvalidator.json [c.o.j.groovy.user.FieldBehaviours] values of dateDuJour variable is --->20/Jun/19
2019-06-20 09:07:31,489 [...] /rest/scriptrunner/behaviours/latest/runvalidator.json [c.o.j.groovy.user.FormField] Error converting string '20/Jun/19' to date using format: d/MMM/yy
It's like the date is good but Jira can't got it like a date...
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.