Hello,
I want to set automatically due date to be the last day of the month. Is there a script for scriptrunner with which to do it?
Thank you in advance
Hi @Kristiyan Nachov ,
you can without a doubt script that (as a behaviour or postfunction, based on your needs), and you can find a lot of info about working with dates here.
However, if scripting does not come easy to you, you might want to try automation for jira (there is a free lite version for server) where you can add a trigger, and then edit the issue with
duedate = {{now.lastBusinessDayOfMonth}}
or
duedate = {{now.endOfMonth}}
hope this helps,
- Tessa
I apologize but I did not explain well. I want the default value of the field Due Date to be the last day of the month. This is the script we used in the previous version of the Jira.
<script type="text/javascript">
var monthNames = [
"Jan", "Feb", "Mar",
"Apr", "May", "Jun", "Jul",
"Aug", "Sep", "Oct",
"Nov", "Dec"
];
var today=new Date();
var dd=today.getDate();
var mm=today.getMonth()+1; //January is 0!
var yyyy=today.getFullYear().toString();
var res = yyyy.substring(2, 4);
var dd = new Date(yyyy, mm, 0);
var d = dd.getDate();
today=d+'/'monthNames
[mm-1]
'/'+res;
dueDateField = AJS.$("#duedate");
if (!dueDateField.val())
{ dueDateField.val(today); }
;
</script>
This script was in description of Due Date field.
However, after we upgraded to version 8.14.1, this is what happened.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kristiyan Nachov ,
You are very right, Javascript in field description is no longer supported from Jira 8+.
Might have mentioned these things right away for quicker resolution ;)
As I mentioned before, you should use a behaviour with groovy script to do this from now on.
Ping if you need a little help with the scripting, but Adaptavist has extensive info available to set you on the right track.
Good luck!
- Tessa
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.
This suggests the script is not interpreted currently due to security reasons.
In case you want to get the functionality back you would need to switch HTML in custom field description back "on".
Please see the following guide:
The option is named: Enable HTML in custom field descriptions and list item values
The background of this change is as follows:
https://jira.atlassian.com/browse/JRASERVER-70859
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It looks great.
But when I enable this function and enter our script, this is the error:
Is the problem in our script?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Probably yes, it complains about Line: 16/Column: 12 - with some likeliness it is not compatible anymore.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<script type="text/javascript">
var monthNames = [
"Jan", "Feb", "Mar",
"Apr", "May", "Jun", "Jul",
"Aug", "Sep", "Oct",
"Nov", "Dec"
];
var today=new Date();
var dd=today.getDate();
var mm=today.getMonth()+1; //January is 0!
var yyyy=today.getFullYear().toString();
var res = yyyy.substring(2, 4);
var dd = new Date(yyyy, mm, 0);
var d = dd.getDate();
today=d+'/'+monthNames[mm-1]+'/'+res;
dueDateField = AJS.$("#duedate");
if (!dueDateField.val())
{ dueDateField.val(today); };
</script>
Thats the script. If somebody needs it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the correction @Daniel Ebers , Tempo stopped supporting extra javascript on the log work screen, but in Jira it is still possible, my bad!
- Tessa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tessa TuteleersNo worries - the moment I clicked "Reply" I even was not sure by 100% anymore - because I read "Jira v8.14" but it seems (?) to work for the OP, however I hope having that understood well :)
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.