I have four check boxes that are called EMP Local Backup, User Share, Email Mailbox, and Email Forwarding. I have validators applied so that when any combination of the first three are checked it then makes the Date Field Retention End Date. If the Email Forwarding is the only one checked it will require Date Field Forwarding End Date. If any of the first three and the email forwarding are checked it requires both.
My issue is that if I check any of the first three it is still requiring the the Forward End Date and if I only select Email Forwarding it is still requiring Retention End Date Field. Below is a screen shot of the code I have. I look forward to talking with you all.
It would be best to use one Custom Script Validator instead of multiple Simple Scripted Validators for your requirement.
Below is an example working code for your reference:-
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.opensymphony.workflow.InvalidInputException
def mutableIssue = issue as MutableIssue
def customFieldManager = ComponentAccessor.customFieldManager
def notificationOptions = customFieldManager.getCustomFieldObjectsByName('Notification Options').first()
def originalDueDate = customFieldManager.getCustomFieldObjectsByName('Original Due Date').first()
def actualDeliveryDate = customFieldManager.getCustomFieldObjectsByName('Actual Delivery Date').first()
def notificationOptionsValue = mutableIssue.getCustomFieldValue(notificationOptions) as String
def originalDueDateValue = mutableIssue.getCustomFieldValue(originalDueDate)
def actualDeliveryDateValue = mutableIssue.getCustomFieldValue(actualDeliveryDate)
if(notificationOptionsValue == "[Email]") {
if(actualDeliveryDateValue != null) {
log.warn "===>>> Email Triggered"
} else {
throw new InvalidInputException("Actual Delivery Date Missing")
}
} else {
if(originalDueDateValue != null) {
log.warn "Others Triggered"
} else {
throw new InvalidInputException("Original Delivery Date Missing")
}
}
Please note, this sample code is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below is a print screen of the validator configuration:-
Also, I include a few test print screens for your reference:-
1) If the Email checkbox is selected and the Actual Delivery Date is not filled in, the validation returns an Error
2) The Email is selected, and the incorrect date is filled up, the validation returns an Error:-
3) This works the same for the other Checkboxes, if the Telephone Call, Social Network or Post option is selected, and the Original Due Date is not filled in, the validator returns an error message:-
4) If the Telephone Call, Social Network or Post option is selected and the incorrect date is selected, the validator will return an error message:-
I hope this helps to answer your question. :)
Thank you and Kind Regards,
Ram
Thank you for your time and effort. This did complete successfully.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Join the largest European gathering of the Atlassian Community and reimagine what’s possible when great teams and transformative technology come together. Plus, grab your Super Fan ticket now and save over €1,000 on your pass before prices rise on 3 June.
Register nowOnline 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.