nuBeforeSave() data validation using Lookup fields
Posted: Tue Aug 23, 2022 5:08 pm
Hi, a simple question...
I have nuBeforeSave() validation working, based on the Code Library entry: "Edit Screen: How to validate form entries before saving?".
That example does not use any Lookup fields though. I need to check that the Lookup is set to one particular value (out of about five possibilities) and disallow saving unless that is the case.
In code, I can get the primary key value for the currently populated/displayed Lookup field on the form, but I would prefer not to check against hard-coded key primary key values in my data validation code!
Is there a way, in JavaScript, of fetching the value that is actually displayed on the form in the Lookup field instead of the primary key value associated with that displayed value, that I am currently getting with:-
keyValue = $('#lookup_field_id').val();
(If not possible, I guess I would have to look up the field with some simple SQL, but I am hoping that validation of forms that have Lookup fields is a fairly common requirement and that there is an easy way to do this...?).
I have nuBeforeSave() validation working, based on the Code Library entry: "Edit Screen: How to validate form entries before saving?".
That example does not use any Lookup fields though. I need to check that the Lookup is set to one particular value (out of about five possibilities) and disallow saving unless that is the case.
In code, I can get the primary key value for the currently populated/displayed Lookup field on the form, but I would prefer not to check against hard-coded key primary key values in my data validation code!
Is there a way, in JavaScript, of fetching the value that is actually displayed on the form in the Lookup field instead of the primary key value associated with that displayed value, that I am currently getting with:-
keyValue = $('#lookup_field_id').val();
(If not possible, I guess I would have to look up the field with some simple SQL, but I am hoping that validation of forms that have Lookup fields is a fairly common requirement and that there is an easy way to do this...?).