One Customer with multiple billing address

bteredesai
Member Posts: 129
Hi,
I have one customer with a single billing address and multiple ship-to-location. At transaction level I wanted to select the customer based on his ship-to-location. Is this possible and how?
Thanks in advance.
Bhushan
I have one customer with a single billing address and multiple ship-to-location. At transaction level I wanted to select the customer based on his ship-to-location. Is this possible and how?
Thanks in advance.
Bhushan
0
Comments
-
The ship-to address allows you to store different ship-to addresses against a customer. At the time of order entry, you can override the ship-to address as well.Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book0 -
Hi Alex,
Thank you for your prompt reply. I wanted to know how to override the ship-to-address at the time of order entry. I am very new to this system.
Thanks.
Bhushan0 -
bteredesai wrote:I wanted to know how to override the ship-to-address at the time of order entry. I am very new to this system.
Basically you cannot with standard NAV logic unless you manually overwrite the address lines in the Shipping tab of the Sales Order. This is because the moment you enter the Sell-to Customer No., standard NAV behavior will assume the same for Bill-to Customer No. and use the same address for Ship-to Code as well but it does NOT enter a Ship-to Code. I believe this is a design flaw because if you have a Customer No. and NULL Ship-to Code it becomes 1-to-zero relationship. Instead NAV copies the address lines from Sell-to Customer (but not the key) as if there was a 1-to-1 relationship.
However you can override this behavior with a little custom programming effort, which we have done, where you will need to modify the Sales Header, Customer, and Ship-to Address tables. We realized this limitation not long after we started using Navision so we implemented the following:
1. Add a custom field in Ship-to Address table called Default (Boolean).
2. In the Ship-to Address table add the following code in Default - OnValidate(). If you are trying to add a second Ship-to Address, the Default address will still be the first Ship-to Address you previously selected until you change it.{ IMPLEMENTATION: Each customer must have one default ship-to address. This may be a different address from the customer address. It is possible for a customer to have multiple ship-to addresses. A validation must be done to ensure there is only one default address. } Default - OnValidate() IF Default = TRUE THEN BEGIN ShipToAddr.RESET; ShipToAddr.SETRANGE("Customer No.",xRec."Customer No."); ShipToAddr.SETFILTER(Code,'<>%1',xRec.Code); ShipToAddr.MODIFYALL(Default,FALSE); END;
3. Create a function GetDefaultShipToCode(CustNo) in Ship-to Address table where it will return the default Ship-to Code.GetDefaultShipToCode(CustNo : Code[20]) : Code[10] WITH ShipToAddr DO BEGIN RESET; SETRANGE("Customer No.",CustNo); SETRANGE(Default,TRUE); IF FINDFIRST THEN EXIT(Code); END;
4. In the Customer table add another function called UpdateSelfShipToAddress() in the OnModify() trigger which will automatically create or update a Ship-to Address record using the same address and contact info in the Customer Card every time you add a new customer or modify and existing record. The Ship-to Code will be the same as the Customer No.UpdateSelfShipToAddress(VAR Cust : Record Customer) { PRE-CONDITION: Customer record must exist. POST-CONDITION: A Ship-to Address record is created or updated. IMPLEMENTATION: Add or modify an existing Ship-to Address using a Customer record. Because of the field length different between Customer."No." and "Ship-to Address".Code user cannot use a Customer No. more than 10 characters long. } IF ShipToAddr.GET(Cust."No.",COPYSTR(Cust."No.",1,10)) THEN ModifySelfShipToAddress(ShipToAddr,Cust) ELSE CreateSelfShipToAddress(Cust); ModifySelfShipToAddress(VAR ShipToAddr : Record "Ship-to Address";VAR Cust : Record Customer) WITH ShipToAddr DO BEGIN Name := Cust.Name; "Name 2" := Cust."Name 2"; Address := Cust.Address; "Address 2" := Cust."Address 2"; City := Cust.City; Contact := Cust.Contact; "Phone No." := Cust."Phone No."; "Telex No." := Cust."Telex No."; "Shipment Method Code" := Cust."Shipment Method Code"; "Shipping Agent Code" := Cust."Shipping Agent Code"; "Place of Export" := Cust."Place of Export"; "Country Code" := Cust."Country Code"; "Last Date Modified" := DT2DATE(CURRENTDATETIME); "Location Code" := Cust."Location Code"; "Fax No." := Cust."Fax No."; "Telex Answer Back" := Cust."Telex Answer Back"; "Post Code" := Cust."Post Code"; County := Cust.County; "E-Mail" := Cust."E-Mail"; "Home Page" := Cust."Home Page"; "Tax Area Code" := Cust."Tax Area Code"; "Tax Liable" := Cust."Tax Liable"; "Shipping Agent Service Code" := Cust."Shipping Agent Service Code"; "Service Zone Code" := Cust."Service Zone Code"; IF PostCode2.GET("Post Code",City) THEN "State Code" := PostCode2."State Code"; VALIDATE(Default,TRUE); MODIFY(TRUE); END; CreateSelfShipToAddress(VAR Cust : Record Customer) WITH ShipToAddr DO BEGIN INIT; "Customer No." := Cust."No."; Code := COPYSTR(Cust."No.",1,10); Name := Cust.Name; "Name 2" := Cust."Name 2"; Address := Cust.Address; "Address 2" := Cust."Address 2"; City := Cust.City; Contact := Cust.Contact; "Phone No." := Cust."Phone No."; "Telex No." := Cust."Telex No."; "Shipment Method Code" := Cust."Shipment Method Code"; "Shipping Agent Code" := Cust."Shipping Agent Code"; "Place of Export" := Cust."Place of Export"; "Country Code" := Cust."Country Code"; "Last Date Modified" := DT2DATE(CURRENTDATETIME); "Location Code" := Cust."Location Code"; "Fax No." := Cust."Fax No."; "Telex Answer Back" := Cust."Telex Answer Back"; "Post Code" := Cust."Post Code"; County := Cust.County; "E-Mail" := Cust."E-Mail"; "Home Page" := Cust."Home Page"; "Tax Area Code" := Cust."Tax Area Code"; "Tax Liable" := Cust."Tax Liable"; "Shipping Agent Service Code" := Cust."Shipping Agent Service Code"; "Service Zone Code" := Cust."Service Zone Code"; IF PostCode2.GET("Post Code",City) THEN "State Code" := PostCode2."State Code"; VALIDATE(Default,TRUE); INSERT(TRUE); END;
5. In the Sales Header table add the following code after the last line in Sell-to Customer No. - OnValidate. This ensures a Sales Order always has a Ship-to Code (remember this 1-to-1 relationship).IF "Document Type" IN ["Document Type"::Order] THEN BEGIN IF "Ship-to Code" = '' THEN "Ship-to Code" := ShipToAddr.GetDefaultShipToCode("Sell-to Customer No."); // Returns the default ship-to code VALIDATE("Ship-to Code");
This works like a charm because now you can also change the Default Ship-to Address any time by simply selecting the Default checkbox in the Ship-to Address Card. Next time you create a Sales Order NAV will enter a Default Ship-to Code and address lines you set up for this code.
Scott0 -
[Topic moved from Retail Management System to Navision forum]0
-
bteredesai wrote:Hi Alex,
Thank you for your prompt reply. I wanted to know how to override the ship-to-address at the time of order entry. I am very new to this system.
Thanks.
Bhushan
If you set some ship-to codes for a customer from the customer card, when entering an order click on the shipping tab and change the Ship-To code to the shipping address you want.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions