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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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 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 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 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 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 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 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
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

4,567 views 12 8
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you