Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Lookup Value not saved

Questions related to using nuBuilder Forte.
Post Reply
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Lookup Value not saved

Unread post 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
You do not have the required permissions to view the files attached to this post.
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Lookup Value not saved

Unread post by admin »

kev1n,

What do suggest?


Steven
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: Lookup Value not saved

Unread post 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
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: Lookup Value not saved

Unread post 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');
	}

}
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: Lookup Value not saved

Unread post 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
You do not have the required permissions to view the files attached to this post.
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Lookup Value not saved

Unread post 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
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: Lookup Value not saved

Unread post by kev1n »

HI Steven,

I like the way you implemented it and it seems to work well.
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Lookup Value not saved

Unread post by admin »

.
Post Reply