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?