Dear all,
I'm currently trying to implement a custom field whose content should be calculated according to some other fields in the issue.
One part of the formula is to calculate the amount of workdays between two dates.
I already managed to calculate the days in between two dates but I only want to get the real workdays - so that Saturdays and Sundays are not included.
Would be great if you can help me with that.
Currently the calculation for days in between two days looks like this:
((new Date()).getTime())-(issue.get("customfield_10440").getTime())
Thanks for your help!
Kind regards,
Markus
Community moderators have prevented the ability to post new answers.
Finally I found the issue. The return value wasn't casted right - it seems that JIRA gets problems especially when creating the issue.
Thanks for your help.
Hello, may I ask how did you managed to count workdays of the specific issue excluding the holidays and weekends? Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I investigated the code today but I didn't manage to fix it.
So I created a new script field and only added "return 10;" - that's it.
Suprisingly this also didn't work and JIRA still says: Error creating issue: Error occurred while creating issue. This could be due to a plugin being incompatible with this version of JIRA. For more details please consult the logs, and see:http://confluence.atlassian.com/x/3McB.
So it has nothing to do with wrong coding - do you have ideas what else it could be?
I use Script Runner 2.1.16
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I need to check - unfortunately I don't have direct access to the server and would need to ask IT for log files.
How could i try out if this is the root cause. How can I include a condition, so that code is only executed once the issue is created? (or only on update)
Kind regards,
Markus
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your answer Andreas!
I managed to implement a similar function than supposed in the link. It works fine on existing issues but when I want to create new ones it says: Error creating issue: Error occurred while creating issue. This could be due to a plugin being incompatible with this version of JIRA. For more details please consult the logs, and see: http://confluence.atlassian.com/x/3McB .
Do i need to consider sth. else? E.g. that the script is only executed on a specific event? Could it be that it can't get the values of the fields since the issue isn't already present?
Kind regards,
Markus
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For more details please consult the logs
Well, was does the logs say? But I also think that is has to do with not-yet-created data for new issues.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That is not a trivial task. If you want to do it correctly, you should also exclude holidays from the "amount of workdays". And which holidays apply depends on your country and maybe even your state or region.
I would probably loop through all days from issue.get("customfield_10440") to new Date(), and check for each date if it is a workday or not, and add +1 if it is a workday. Something like this stackoverflow answer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.