Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

SIL Script to count Workday

Carla Dumale November 6, 2018

Hi, I want to create custom field to count the age/workday based on the creation date field, excluding the Holidays and Week ends. Can anyone help? I am using Jira-cloud. Thanks!

1 answer

1 accepted

1 vote
Answer accepted
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 6, 2018

Hello,

The Cloud architecture does not support scripted custom fields, that is why you can not do it on Cloud.

Carla Dumale November 6, 2018

Thanks for the answer. But as of now, we are using plug-ins to add SIL in some of the custom field. Now I want to add custom field wherein I can count the days since the issue has been created, excluding holidays and weekends.

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 6, 2018

I am not sure how you add a sil script to a custom field in Cloud. But if you can do it, then you should use this function:

number days;
date startDate = "2012-01-10 12:00:00";
date endDate = "2012-01-20 10:30:00";
string startHour = "09:00";
string endHour = "17:00";
number[] weekend = {7, 1};
date[] holidays = {"2012-01-18", "2012-01-16"}; 
number hours = getWorkingInterval(startDate, endDate, startHour, endHour, weekend, holidays);
days = hours/8;
return days;
Like Alexander Bondarev likes this
Carla Dumale November 7, 2018

Thank you! :) This helped. I got another query, how can I make it possible to start the counting the number of workday on next day? E.g. When issue was created today, the start of counting of workday will be tomorrow. 

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 7, 2018

I think it should be like this:

number days;
date startDate = created;
startDate = startDate + "1d";
date endDate = "2012-01-20 10:30:00";
string startHour = "09:00";
string endHour = "17:00";
number[] weekend = {7, 1};
date[] holidays = {"2012-01-18", "2012-01-16"}; 
number hours = getWorkingInterval(startDate, endDate, startHour, endHour, weekend, holidays);
days = hours/8;
return days;
Carla Dumale November 7, 2018

Yes, this is also the solution I came up with. Last question ^^, how to make the counter stop once the status has been resolved, and continue while it remains unresolved? Thank you for the help!

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 7, 2018

You would need to combine the script above with this one:

https://confluence.cprime.io/display/TR/Get+time+spent+in+certain+status+per+issue

Carla Dumale November 7, 2018

Thank you so much~ :) 

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 8, 2018

You are welcome!

Suggest an answer

Log in or Sign up to answer