Hi,
We need to make a field mandatory if the Start Date didn't pick up five working days earlier. Otherwise, if the condition is true field must be hidden from the reporter. If someone met up the same or similar problem?
I appreciate any help you can provide.
Hi @Narek Zohrabyan If i am understanding it correctly , you want to hide another field ( may i know type of this field) , based on this condition like Start Date = CurrentDate < -5 days ?
Thanks
Vikrant Yadav
Hello @Vikrant Yadav ,
Thank you for your response.
Condition is true until the Start Date >= Current Date - 5 working days (skipping weekends). The custom field type will be a checkbox and hidden until the condition won't be true and it will be required.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can use below code to hidding and unhiding checkbox field . For weekends, @PD Sheehan @Ram Kumar Aravindakshan _Adaptavist_ Kindly suggest..i am not sure how to check for weekends.
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import com.atlassian.jira.component.ComponentAccessor
import java.sql.Timestamp
import java.time.DayOfWeek
@BaseScript FieldBehaviours fieldBehaviours
def dateField = getFieldById(fieldChanged)//Start Date
def dateValue = dateField.value as Date
def checkbox_field = getFieldById("customfield_23445")
//def weekend = EnumSet.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY)
def today = new Date().minus(6)
if (dateValue > today) {
checkbox_field.setHidden(false)
} else {
checkbox_field.setHidden(true)
checkbox_field.setRequired(true)
}
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is a short function that can return the date based on a number of business days ago
import groovy.time.TimeCategory
def busDayAgo(startDate, nDays){
def ago=startDate
(0..nDays).each{
use(TimeCategory){
ago = ago.minus(1.day)
(ago.day in [0,6]) && (ago = ago.minus(1.day))
}
}
ago
}
busDayAgo(new Date(),5)
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.