Hi all,
I have a requirement in our project. We have 3 custom fields Start Date(Date field), End Date(Date field) and Outside Window(Check box). If the date selected in Start Date and End Date fields is between 8 AM - 6 PM and from Mon-Fri then Outside Window should be enabled and this requirement is for the Create Screen.
Can someone help me with this requirement.
Hi @Pavan Chiti
You would need an app like ScriptRunner, it has a behaviour functionality which can let you add this dynamic features on the create issue screen. Take a look at some sample scripts as well.
Ravi
My apologies for not replying earlier.
I was working on the ScriptRunner behavior script and was able to get the expected result.
I just started using ScriptRunner and let me know if this script is good enough.
Below is the script I used.
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import java.util.Date
import java.util.Calendar
def startDateCF = getFieldByName("Start Date")
def startDateValue = startDateCF.getValue() as Date
def endDateCF = getFieldByName("End Date")
def endDateValue = endDateCF.getValue() as Date
def outsideCF = getFieldByName("Outside Window")
outsideCF.setReadOnly(true)
if (startDateValue.getAt(Calendar.DAY_OF_WEEK) in [Calendar.SATURDAY, Calendar.SUNDAY])
outsideCF.setFormValue(['No'])
else {
outsideCF.setFormValue(['Yes'])
}
if (startDateValue.getAt(Calendar.DAY_OF_WEEK) in [Calendar.MONDAY, Calendar.TUESDAY, Calendar.WEDNESDAY, Calendar.THURSDAY, Calendar.FRIDAY])
if (startDateValue.getAt(Calendar.HOUR_OF_DAY) > 8 || (startDateValue.getAt(Calendar.HOUR_OF_DAY) < 18)
outsideCF.setFormValue(['Yes'])
else {
outsideCF.setFormValue(['No'])
}
if (endDateValue.getAt(Calendar.DAY_OF_WEEK) in [Calendar.SATURDAY, Calendar.SUNDAY])
outsideCF.setFormValue(['No'])
else {
outsideCF.setFormValue(['Yes'])
}
if (endDateValue.getAt(Calendar.DAY_OF_WEEK) in [Calendar.MONDAY, Calendar.TUESDAY, Calendar.WEDNESDAY, Calendar.THURSDAY, Calendar.FRIDAY])
if (endDateValue.getAt(Calendar.HOUR_OF_DAY) > 8 || (endDateValue.getAt(Calendar.HOUR_OF_DAY) < 18)
outsideCF.setFormValue(['Yes'])
else {
outsideCF.setFormValue(['No'])
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Very nice. Well if it works then all good. Just add some error handling for null values but overall looks good.
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.