Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Automatic set Due Date the end of the month

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

1 answer

1 accepted

0 votes
Answer accepted
Tessa Tuteleers
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 02, 2021

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.Capture.JPG

Tessa Tuteleers
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 02, 2021

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

Thank you very much.

I am starting to explore adaptavist.

Daniel Ebers
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 02, 2021

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:

https://confluence.atlassian.com/adminjiraserver087/configuring-jira-application-options-998872637.html

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

It looks great.

But when I enable this function and enter our script, this is the error:

Capture.JPG

 

Is the problem in our script?

Daniel Ebers
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 03, 2021

Probably yes, it complains about Line: 16/Column: 12 - with some likeliness it is not compatible anymore.

<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.

Like Tessa Tuteleers likes this
Tessa Tuteleers
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 03, 2021

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

Daniel Ebers
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 03, 2021

@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 :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events