Lookup Updating

Lookup Updating

Postby Eppo » Tue Mar 11, 2014 11:15 pm

Hi There,

Since I have imported an older database from the replaced system. I have a problem with my lookup update script.
Code: Select all
function nuLoadThis() {

   if($('#recordID').val() == '-1'){
      $('#codekoop_klanten_id').change();
   }

}

I found this little script on http://forums.nubuilder.com/viewtopic.php?f=4&t=8047&p=10885&hilit=lookup+update#p10885 and it works great. Only when I have a customer (from the imported customers) and I want to put in a extra bought product, it wil only blink in the lookup field and wil not update some other fields Like when you do if you Look it up yourself (thats where this smal piece of script is for). With normal entered customers it works as it should be.

The Imorted customers have ID nummers 106000001 and counting
The normal customers have ID numbers like 1531f0b75ca3b2.

With the purchased products I have got the same problem and they got ID nummer 1919000001 and counting.

Can You help me with my problem. and do you know if this works better in the Pro version?

Thanks

Jeroen
Eppo
 
Posts: 29
Joined: Tue Jan 15, 2013 12:19 am
Location: The Netherlands, Leiden

Re: Lookup Updating

Postby massiws » Sat Mar 15, 2014 12:50 pm

Eppo, are you saying that in customer table you have both records with ID build by nuBuilder with uniqid() function and records with numeric ID?Maybe this could be the problem...
Try to clone an imported record: nuBuilder assign to it a uniqid PK and you can see if it works.

Max
massiws
 
Posts: 503
Joined: Thu May 24, 2012 9:38 am
Location: Milan, Italy

Re: Lookup Updating

Postby Eppo » Tue Mar 18, 2014 7:35 pm

Max,

All of my imported consumers have 1 uniq ID. That is like 106000001 or New Customers have ID's like 1531f0b75ca3b2.

If I clone an imported customer with then it gets a ID like 1531f0b75ca3b2, but then is there no connection with my bought products witch are allready in the system.

I have got 8000 customers imported and over 30.000 bought products, so change them manualy isn't realy an option.

Can Import them again only with a new bigger number be an solution?

Thanks for keeping up the good work! :D

Jeroen
Last edited by Eppo on Tue Mar 18, 2014 8:26 pm, edited 1 time in total.
Eppo
 
Posts: 29
Joined: Tue Jan 15, 2013 12:19 am
Location: The Netherlands, Leiden

Re: Lookup Updating

Postby Eppo » Tue Mar 18, 2014 8:09 pm

I've manualy changed 2 customers and there bought products to customer ID like ab106c619014751. And that is not a solution. I stil got the same error.

Maybe steve has a solution?

Thanks!

Jeroen
Eppo
 
Posts: 29
Joined: Tue Jan 15, 2013 12:19 am
Location: The Netherlands, Leiden

Re: Lookup Updating

Postby massiws » Tue Mar 18, 2014 11:36 pm

Jeroen,
I made some tests on my db, changing some customer IDs to integer numbers (like your 106000001) but all works fine, also edit existing or adding new products.
Some suggestions:
  • are you sure that "ab106c619014751" is a uniqid code? It must be build with PHP uniqid() function (13 characters long);
  • PK and FK fields in MySQL must be the same type and size;
  • inspect with Firebug console: do you see any error when you pick up a new record in subform?
massiws
 
Posts: 503
Joined: Thu May 24, 2012 9:38 am
Location: Milan, Italy

Re: Lookup Updating

Postby Eppo » Wed Mar 19, 2014 10:31 pm

Hi Max,

All of the customers have a Uniq number witch is given from in the old program, so I assume it is not created with PHP uniqid() function. When I imported it into phpmyadmin it did not gave me a error. Klanten_id is a UNIQUE KEY (klanten is consumers in dutch).
- So if you say that I have to change the ID's to a 13 digit number with or without some letters I can do that, but I don't think that it wil work because i just found out that some of the new consumers (with have a nubuilder Uniq ID) have the same problem.
- What do you mean with PK and FK fields? al the ID fiels are varchar(15) NOT NULL. Like the sample_nufinancial module.

With Firebug I see this for the lookup field
Code: Select all
<td class="selected" style="text-align:left">
<input id="koop_klanten_id" type="hidden" value="106015396" name="koop_klanten_id">
<input id="codekoop_klanten_id" class="lookupcode" onclick="edit_lookup('151629be0a29d0', 'koop_klanten_id')" ondblclick="if(nuShiftKey){nuMoveObject(this.id.substring(4), 0,0);return;};nuControlKey=true;openIBrowse('151629ec00930e', '', '', '153298b8b1a6cf', '1532991f197417')" accept="151629ec00930e" onfocus="nuSetRow('');" onchange=";" style="width:144px;" value="Aalbersberg" name="codekoop_klanten_id">
<img id="luup_koop_klanten_id" class="lubutton" onclick=" nuSetRow(''); nuControlKey=true;openIBrowse('151629ec00930e', '', '', '153298b8b1a6cf', '1532991f197417') " onmousedown=" this.src='ludown.png'" onmouseout=" this.src='luup.png' " onmouseup=" this.src='luup.png' " style="vertical-align:text-bottom" alt="Lookup" src="luup.png">
<input id="descriptionkoop_klanten_id" type="hidden" tabindex="10000" readonly="readonly" style="width:0px;" value="" name="descriptionkoop_klanten_id">
</td>

And this for de the field that has to be updated.
Code: Select all
<td class="selected" style="text-align:left;white-space: nowrap;">
<input id="koop_klant_naam" class="readonly" type="text" tabindex="10000" readonly="readonly" ondblclick="if(nuShiftKey){nuMoveObject(this.id, 0,0);return;};" onfocus="nuSetRow('');" onchange="uDB(this,'text');" style="width:240px;text-align:left;vertical-align:top;" name="koop_klant_naam">
</td>


I don't see any wrong things, I hope you see something.

Thank allready for helping me.

Jeroen
Eppo
 
Posts: 29
Joined: Tue Jan 15, 2013 12:19 am
Location: The Netherlands, Leiden

Re: Lookup Updating

Postby massiws » Thu Mar 20, 2014 8:33 am

Jeroen, sorry but I can't reproduce your error.
Eppo wrote:...if you say that I have to change the ID's to a 13 digit number with or without some letters I can do that, but I don't think that it wil work because i just found out that some of the new consumers (with have a nubuilder Uniq ID) have the same problem.

If you say that the problem appear also with record created with nuBuilder then problem is not related to IDs.

To understand why some record works fine and others fail, try to inspect your script, displaying variable values:
Code: Select all
function nuLoadThis() {
   console.log("recordID: " + $("#recordID").val() + " - LU: " + $("#codekoop_klanten_id").val() );
   if($('#recordID').val() == '-1'){
      $('#codekoop_klanten_id').change();
   }
}


Hope this helps,
Max
massiws
 
Posts: 503
Joined: Thu May 24, 2012 9:38 am
Location: Milan, Italy

Re: Lookup Updating

Postby Eppo » Thu Mar 20, 2014 10:18 pm

Max,


Maybe a stupid question, but where can I found the log of this script?


Jeroen
Eppo
 
Posts: 29
Joined: Tue Jan 15, 2013 12:19 am
Location: The Netherlands, Leiden

Re: Lookup Updating

Postby massiws » Thu Mar 20, 2014 11:41 pm

It's the Firebug console:
FirebugConsole.png
Display log in Firebug Console
FirebugConsole.png (15.69 KiB) Viewed 8918 times
massiws
 
Posts: 503
Joined: Thu May 24, 2012 9:38 am
Location: Milan, Italy

Re: Lookup Updating

Postby Eppo » Fri Mar 21, 2014 4:37 am

I found it.

This are the answer: I have found 1 customer where it realy works...
Image

Al of the other (tested) customers give this reaction.
Image
Number 14 is every time a different number.

I hope you see something thats wrong.

Thanks!

Jeroen
Eppo
 
Posts: 29
Joined: Tue Jan 15, 2013 12:19 am
Location: The Netherlands, Leiden

Next

Return to General