web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Retrieve an existing address for a specific customer

(0) ShareShare
ReportReport
Posted on by 8
Hello,
I have a requirement where I need to create a sales order from a web service.
The web service response will send information regarding the client and address information Address, LocationName, City, CountryRegionId and ZipCode.
If the 5 address field information have values then an address should be created for the customer.
We have noticed an issue with this as if several orders for the same client (and same address values) are being created, then technically the same address will be created multiple times.
To fix this, I have added a logic to check if an address based on the values exist for the customer in DirPartyPostalAddressView then I retrieve the postalAddressRecId instead of creating a new address.
However, the request is not returning any records.
I have created a test class to test but same results (The record exists for the values inserted when I checked in T-SQL):
DirPartyPostalAddressView   addressView;
        LogisticsPostalAddress postalAddress;
        DirPartyRecId party = 5637199605;
        utcdatetime datenow = DateTimeUtil::utcNow();
 
Request 1
        select firstonly1 validtimestate(datenow) postalAddress
            join  addressView
            order by addressView.IsPrimary desc
            where postalAddress.RecId == addressView._RecId_LogisticsPostalAddress && 
                  addressView.Party             == party &&
                  addressView.Address           == 'Address 123 %1' &&
                  addressView.LocationName      == 'ClientA' &&
                  addressView.City              == 'City1' &&
                  addressView.CountryRegionId   == 'CT' &&
                  addressView.ZipCode           == 'XXXXX';
 
Request 2
        select firstonly1 addressView
            order by addressView.IsPrimary desc
            where addressView.Party             == party &&
                  addressView.Address           == 'Address 123 %1' &&
                  addressView.LocationName      == 'ClientA' &&
                  addressView.City              == 'City1' &&
                  addressView.CountryRegionId   == 'CT' &&
                  addressView.ZipCode           == 'XXXXX';
 
Request 3
        select firstonly1 addressView
            order by addressView.IsPrimary desc
            where addressView.Party             == party &&
                  addressView.Address           == 'Address 123 %1' &&
                  addressView.LocationName      == 'ClientA' &&
                  addressView.City              == 'City1' &&
                  addressView.CountryRegionId   == 'CT' &&
                  addressView.ZipCode           == 'XXXXX' &&
addressView.ValidFrom <= datenow  &&
addressView.ValidTo >= datenow ;
 
All the requests are not returning any record.
Is there any way to retrieve an address based on this criteria?
I have the same question (0)
  • Jason0810M Profile Picture
    8 on at
    Just as a note.
    I have noticed that the issue is probably due to the %1 symbol in the address.
    In T-SQL the address value of the record view is 'Address 123 %1' and same as the web service request.
    I have omitted the addressView.Address check in the select statement and it has ultimately returned the record with the addressView.Address field value being 'Address 123 TheCountryName' instead of 'Address 123 %1'.
  • André Arnaud de Calavon Profile Picture
    303,381 Super User 2026 Season 1 on at
    Hi Jason,
     
    It could be indeed related to "%1" in the address, but I'm not sure. Is this really a valid part of an address? Can you test with an address without this "%1"?
  • Verified answer
    Jason0810M Profile Picture
    8 on at
    Hello Andre,
    I have found the issue.
    Indeed there is a logic in the postLoad of the LogisticPostalAddressView which checks if the Address field value contains %1 and then sets it to the name of the record country region accordingly.
    I have done the same for my custom web service address field value and use it for the select statement.
    It works fine now.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 514 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 390

#3
Adis Profile Picture

Adis 266 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans