Form validation for a lookup field
I'm trying to write deluge validation to check a multi-select lookup field for selections made by the user before the record is added or edited. I've wrote scripts for the On Add and On Edit form actions of the Submit button, but I'm not having success and get an error mentioning the mismatch in my expression (field type is BIGINTLIST on left, but String on right). I guess I'm using the incorrect operator ==. I also tried doing a count of the list, but wasn't successful there either.
The number of selections made in this field is conditional and can be zero or more depending on the value the preceding field (input.school_level_documentation). Here's a sample of what I came up with.
- if ((input.School_level_documentation == "Yes") && (input.School_List == ""))
- {
- alert "For school-level documentation, at least one school selection is required. Please select and try again.";
- cancel submit;
- }
- else if ((input.School_level_documentation == "No") && (input.School_List != ""))
- {
- alert "For non-school documentation, school selections are prohibited. Please remove and try again.";
- cancel submit;
- }
Also tinkering with a script to clear School_List based on the selection in the School_level_documentation field. This would be ideal and could eliminate the 'else if' condition. Appreciate any guidance on that, too!