Page 1 of 1
Lookup Value not saved
Posted: Sat Aug 15, 2020 11:23 am
by kev1n
Hi,
If a value is entered manually in a Lookup Object (without pressing tabulator), It is not stored in the database.
(Because the Lookup's AJAX request is not finished by the time the form is saved.)
lookup_not_saved.gif
Re: Lookup Value not saved
Posted: Sun Aug 16, 2020 1:48 am
by admin
kev1n,
What do suggest?
Steven
Re: Lookup Value not saved
Posted: Sun Aug 16, 2020 6:47 am
by kev1n
There is another scenario when saving does not work as expected:
1. A value has been picked in a lookup field (e.g. FF1).
2. Clear the field
3. Hit Save
Result: FF1 is still stored to the DB.
lookup_not_saved2.gif
Re: Lookup Value not saved
Posted: Sun Aug 16, 2020 6:54 am
by kev1n
admin wrote:
What do suggest?
The easiest way is probably to check whether the lookup description is empty but a value is entered in the lookup code. (Or if the description is not empty and the value is blank)
Then display a message that the lookup operation is still in progress.
Of course, this can be further improved.
Like detecting when the lookup operation is complete and if a save operation is "pending", save the form. But for now, that should serve the purpose.
Code: Select all
function nuLookupPending() {
var p = false;
$('[data-nu-type="lookup"][id$="code"]').each(function(){
var d = $('#' + this.id.slice(0, -4) + 'description');
p = (d.val() == '' && $(this).val() !== '') || (d.val() !== '' && $(this).val() == '')
return false;
});
return p;
}
function nuSaveAction(){
if (nuLookupPending()) {
nuMessage([nuTranslate('A lookup operation is still in progress. Please save again when complete.')]);
return;
}
if(nuNoDuplicates()){
nuUpdateData('save');
}
}
Re: Lookup Value not saved
Posted: Sun Aug 16, 2020 9:57 am
by kev1n
Next up, let's this fix in action:
1. Enter a code and save
lookup_fix_in_action_1.gif
2. Clear a code and save
lookup_fix_in_action_2.gif
Re: Lookup Value not saved
Posted: Tue Aug 18, 2020 3:04 am
by admin
kev1n,
I've added a Lookup checking thing before saving a record.
Its now on Github.
(Not exactly what you suggested but thanks anyway)
Please test it.
Steven
Re: Lookup Value not saved
Posted: Tue Aug 18, 2020 4:06 am
by kev1n
HI Steven,
I like the way you implemented it and it seems to work well.
Re: Lookup Value not saved
Posted: Tue Aug 18, 2020 5:28 am
by admin
.