Custom Ship-to Address field not transferring to order header

I have created a custom field in the Ship-to Address table (222) that I would like to transfer to the sales order header (36.) This field is for the customer’s collect freight account number and is only found in the Ship-to table.

I used the same field no., exact same name, type and length in the order header and ship-to tables. I inserted the field into both forms.

When running the sales order form though, the custom field in the header is not populated.

According to the advice I got from my solution provider, this should be all I have to do. What could I be doing wrong?

Hi,

If you have access to NAV Code, then you can do it otherwise contact your solution centre.

You will find following code on No.-OnValidate trigger of table 36(Sales header):

ShipToAddr.GET(“Sell-to Customer No.”,“Ship-to Code”);
“Ship-to Name” := ShipToAddr.Name;
“Ship-to Name 2” := ShipToAddr.“Name 2”;
“Ship-to Address” := ShipToAddr.Address;
“Ship-to Address 2” := ShipToAddr.“Address 2”;
“Ship-to City” := ShipToAddr.City;
“Ship-to Post Code” := ShipToAddr.“Post Code”;
“Ship-to County” := ShipToAddr.County;
VALIDATE(“Ship-to Country/Region Code”,ShipToAddr.“Country/Region Code”);
“Ship-to Contact” := ShipToAddr.Contact;
“Shipment Method Code” := ShipToAddr.“Shipment Method Code”;

You need to add 1 line there for populating your custom field, for example:

YourCustomFieldInSalesHeader:=ShipToAddr.YourCustomFieldIInShipToAddress;

This may also be required in following code in same trigger:

IF “Sell-to Customer No.” <> ‘’ THEN BEGIN
GetCust(“Sell-to Customer No.”);
“Ship-to Name” := Cust.Name;
“Ship-to Name 2” := Cust.“Name 2”;
“Ship-to Address” := Cust.Address;
“Ship-to Address 2” := Cust.“Address 2”;
“Ship-to City” := Cust.City;
“Ship-to Post Code” := Cust.“Post Code”;
“Ship-to County” := Cust.County;
VALIDATE(“Ship-to Country/Region Code”,Cust.“Country/Region Code”);
“Ship-to Contact” := Cust.Contact;
“Shipment Method Code” := Cust.“Shipment Method Code”;

In addition to what I posted earlier, you should add this new custom field to

Sales Shipment Header

& Sales Invoice Header

tables also, keeping the field number same.

Dhan is correct. You have to tell the field what value should be assigned to it. Think about the way you did it for a second. Say you added a new text field to table 222 and table 36 and they both had the same length as Bill-to Address. How would NAV know what field gets assigned where?

Remember, it’s programming. It does EXACTLY what you tell it to do. And you never told anything to be copied to your new field. Follow Dhan’s advice, it’s perfect.

I assumed this was true. It didn’t make any sense otherwise.

@Dhan, thank you for the programming advice. Sadly, my license doesn’t give me access to the code.

Being held hostage by consultants and paying their rates to insert 2 lines of code incenses me. How much is a developer’s license?

Thanks again.

the license is much much much more than paying to have it done. I feel your pain.

You could also create a lookup flowfield that shows this code on the sales header without touching the code.

Create your new sales header field 50000+ range same type & size as the field you created in the ship-to address table.

view the properties of the new sales header field.
Fieldcalss = Flowfield
Calcformula = Lookup(“Ship-to Address”.“YOUR FIELD” WHERE(Customer No.=FIELD(Sell-to Customer No.),CODE=FIELD(Ship-to Code)))
**use the assistedit to get it 100% correct

Drop your new field in on the sales header card.

Save->Compile->Enjoy - But adding that one line of code is really the best way - but you can use that workaround if needed.

If this code is based on Ship-to Address table & each ship-to can have a different “you field” then adding the one line to OnValidate of the “Ship-to Code” is where i would have it put. Not on “No.” as stated above. If the customer has only 1 “freight collect code” then why would it be in the ship-to address table? that table is for other possible shipping options.

**I have read you are trying to impliment on your own. A good tip would be to write down all the little changes you would like to make and submit them all at the same time to a solution center so they can knock it all out at once instead of a little here & a little there. THey usually get payed by the hour not the minute so give them a full hour’s worth of work. good luck!

Thank you! That worked perfectly and was exactly the sort of creative no-budget solution that I was looking for. To pass a simple field around a few forms and documents shouldn’t cost me 100 chickens. And if I decide that I need a custom field to do more than sit there and look pretty, I’ll go to my solution center for help. :slight_smile:

And as far as the Ship-to table is concerned, we use this submenu for areas or departments within a single Sell-to Customer that have unique shipping details, e.g. freight collect accounts and other special instructions that may need to print on the Sales Order and other documents used by the warehouse.

Our Customers are usually large manufacturers with several internal departments, ie. R&D, Quality Control or just general Stores. And of course, the Bill-to is usually a large centralized billing location elsewhere. So, a “Customer” location could have more than one collect account through the Ship-To table.

Cheers!