How to load & assign shipping address from customer file?

When enter Invoice, I enter the customer name via Ajax Text Auto-Complete feature.

My question is, how to retrieve the default ship-to address from the customer master file and PUT to the ship-to fields? And those fields are editable if customer decide to ship-to other address.

Any idea?

Regards,
CK

Re: How to load & assign shipping address from customer file?

Create an AJAX event in the form that uses sc_lookup to get the values, then change the field values

customer_name.onBlur:


$sql = 'select ....';

sc_lookup(tbl_name,$sql);
{field_address_1} = {tbl_name[0][0]};
{field_address_2} = {tbl_name[0][1]};

Regards,
Scott.

Re: How to load & assign shipping address from customer file?

customerid.onBlur

sc_lookup(my_data,“SELECT addr01, addr02 FROM customer WHERE customerid = ‘{customerid}’”);

format 1…
sc_master_value({addr01}, {my_data[0][0]});
sc_master_value({addr02}, {my_data[0][1]});

format 2…
{addr01} = {my_data[0][0]};
{addr02} = {my_data[0][1]};

Both also not working. Those 2 fields remain BLANK.

Re: How to load & assign shipping address from customer file?

You are use the onBlur from customerid. Is that the field that is populated? It should be customer_name … correct?

When they populate and leave the field customer_name, it should then populate. Can you echo the values from the lookup and see if it has data?

Regards,
Scott.

Re: How to load & assign shipping address from customer file?

Even I populated both customerID & customer_name fields, the final result are the same. Addr01 & Addr02 remain BLANK.

Re: How to load & assign shipping address from customer file?

Feel free to send a PM with your email so you can send me an export of your app so I can take a look.

Regards,
Scott.

Re: How to load & assign shipping address from customer file?

Figure out the problem.

Placed under onChange events, It works.
Placed under onBlur event, nothing happen.