Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV forum
Answered

Odata Sales Order Creation - Wrong Zip Code Picked from the Zip Codes table

Posted on by 30

Hi All,

I am creating sales orders in NAV through Odata REST web services, I set "ship_to" details in the JSON of the POST request i.e., City, State, Zip Code and Country. NAV tends to pick up the details which appear 1st on the Zip Codes table based on Zip Code and City. Since same zip code has different city names, I'm facing issue with address mis-match on the sales order and tax calculation.

For instance the order details I set in JSON are as follows:
{

  "Ship_to_City": "Sandstone",
  "Ship_to_County": "MN",
  "Ship_to_Post_Code": "55072",
  "Ship_to_Country_Region_Code": "US"

}

Details about zip code 55072 (from google): 55072, Postal code in Minnesota, Cities: Sandstone, MN, Markville, MN, Cloverton, MN, Duxbury, MN, Kingsdale, MN, Groningen, MN
So same zip code has different city names.

Zip Code Table in NAV: has 2 entries for 55072

Code     City    Country

55072    Markville    US      ----- NAV always picks this details

55072    Sandstone   US    ----- when I try to post with this line details

After creating the sales order, NAV returns the following:
{

  "Ship_to_City": "Markville",
  "Ship_to_County": "MN",
  "Ship_to_Post_Code": "55072",
  "Ship_to_Country_Region_Code": "US"

}

Due to this, the customer order details and what's in NAV do not match up which in-turn causes tax miscalculation in NAV.

From my little understanding of NAV:
1. While creating a new entry in zip codes table, the combination of Zip code and City name is treated as primary/unique key.

2. When I post a sales order, NAV gets all the entries for a zip code and sorts it based on city name to pick the first one from the list.

Please help me resolve the issue.

Thanks in Advance!

Kishore.

  • Kishore22 Profile Picture
    Kishore22 30 on at
    RE: Odata Sales Order Creation - Wrong Zip Code Picked from the Zip Codes table

    Thanks Suresh Kulla, your response definitely helped me.

    My approach:

    1. I just POST the sales order as I used to do it previously.

    2. I compare the Code, City, County and Country in both POST body JSON and NAV response JSON.

    3. If they are different, I do a PUT/PATCH request with correct details.

    And above approach works fine.

    Thanks again,

    Kishore.

  • Verified answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,640 on at
    RE: Odata Sales Order Creation - Wrong Zip Code Picked from the Zip Codes table

    Try setting the city and county values after you set the post code

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,558 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,645 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans