Forums

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

ScritpRunner Behavior or others disallow past date in date custom field depending on the other field

Jurica Petricevic
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.
October 21, 2021

Hi Community,

 

after I have successfully made solutions disallowing past date in date custom field End of project the following problem occurred.

There is a Fixtermin field that has YES / NO values. If Fixtermin is YES then this option is valid and should disallow past date in date custom field End of project.

But if Fixtermin is set to NO, then this field End of project must be able to be left blank or any other value entered.

I have seen similar solutions here. Can anyone help?

 

Best regards

Jurica Petricevic

 

 

1 answer

0 votes
PD Sheehan
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.
October 23, 2021

You would need to add a the same script to both you date field and your select field to be sure the rule is picked up whichever field is updated first:

def dateField = getFieldByName('End of project')
def conditionField = getFieldByName('Fixtermin')

dateField.clearError().setRequired(false)
if(conditionField.value == 'YES'){
if(dateField.value < new Date().clearTime()){
dateField.setError("You may not enter a date before today").setRequired(true)
}
}

If you have users in other timezones from the server, that might require some special considerations. Also, you will want to test scenarios where the issue is edited later. 

Suggest an answer

Log in or Sign up to answer