Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

setting Adress city

(0) ShareShare
ReportReport
Posted on by 619

Hi I want to set city in an adress for a customer (by code). I use the DirParty createOrUpdatePostalAddress method.

Problem: We do have zipcodes in Germany relating to more than 1 city. Now when I try to import the given address, AX (the createOrUpdatePotalAddress method) changes the city to the know one in AX

e.g. ZipCode 16320, Cities: Gruental, Sydower Fliess, Tempelfelde

I want to set Tempelfelde but AX sets Sydower Fliess automatically

Is there a way to stop this behaviour?

  • Suggested answer
    nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: setting Adress city

    You can add it, and develop your own handling for it. Or, use some other solution than this view to create addresses.

  • CRSW Profile Picture
    619 on at
    RE: setting Adress city

    there is no field to set the zipcodrecid in DirPartyPostalAddressView

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: setting Adress city

    Hi CRSW,

    Along with the CityRecId, please try passing the ZipCoideRecId as well. You can use this method in Tables\LogisticsAddressZipCode - findZipCodeCity. This should give you the correct ZipCodeRecId value.

  • CRSW Profile Picture
    619 on at
    RE: setting Adress city

    still not working. somewhere deep inside it searches again for the zipcode table and takes the first record not the one for the cityrecid I pass by

  • nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: setting Adress city

    As mentioned, you should search for the correct record in LogisticsAddressCity. Then put LogisticsAddressCity.RecId in DirPartyPostalAddressView.CityRecId and only then call createOrUpdatePostalAddress method. Then it should work.

  • CRSW Profile Picture
    619 on at
    RE: setting Adress city

      .....

    DirPartyPostalAddressView               address;

    .....

        address.ZipCode             = _request.parmZipCode();

        if(_request.parmCountry() != '')
        {
            address.CountryRegionId     =  LogisticsAddressCountryRegion::findByISOCode(_request.parmCountry()).CountryRegionId;
        }
        else
        {
             address.CountryRegionId     = 'DEU';
        }

        address.IsPrimary           = true;

        address.BuildingCompliment = _request.parmAddressCompliment();
        address.Street             = _request.parmStreet();
        address.StreetNumber       = _request.parmHouseNumber();
        address.ZipCode            = _request.parmZipCode();
        address.City               = _request.parmCity();
      
        dirParty.createOrUpdatePostalAddress(address, [LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Invoice).RecId]);

  • Suggested answer
    Mav Profile Picture
    on at
    RE: setting Adress city

    Hi CRSW,

    Found this hotfix for something similar but for Belgium , may be it will help you.

    Also read that by default Ax would assign it to first city amongst the list of cities for that same zip code , for eg if city a, b & c has zipcode1234 , then Ax by default should show A.

    Now if you want it to show C, then debug to find the code which sets it to first element of the list ,i.e. A & change it from setting to 1st city in the list to last city in the list.

    Please mark verify if this resolved your issue.

    Thanks

    Mav

  • nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: setting Adress city

    You might need to write code that works with CityRecId instead of only City name.

    Anyway, could you share your current code so that we can take a look? Thanks!

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: setting Adress city

    Hi CRSW,

    Could you please share your code and the values you are passing to update the address?

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,245 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,923 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans