From July 9th till 13th we will be at #MSInspire. See you there!

Creating One-Time Address using X++ in AX 2012 R3

Creating One-Time Address using X++ in AX 2012 R3
14 Apr 2017

Creating One-Time Address for the Sales order can be useful in Microsoft Dynamics AX 2012 R3 if you have to link the Postal Address only with the Sales Order and not with the customer. This Address will not be added in the Customer Address book.

F3ComAxPostalAddressDocument is the document class for postal address. First we have to map the values with LogisticsPostalAddress and create record in the table. Here is the code for that:

public RecId createOneTimeAddress(F3ComAxPostalAddressDocument f3PostalAddressDocument)
{
LogisticsPostalAddress logisticsPostalAddress;
LogisticsPostalAddressEntity postalAddressEntity;
LogisticsPostalAddressView addressView;
DirPartyPostalAddressView partyAddressView;

logisticsPostalAddress.Street = f3PostalAddressDocument.parmStreet();
logisticsPostalAddress.City = f3PostalAddressDocument.parmCity();
logisticsPostalAddress.ZipCode = f3PostalAddressDocument.parmZipCode();
logisticsPostalAddress.State = f3PostalAddressDocument.parmState();
logisticsPostalAddress.CountryRegionId = f3PostalAddressDocument.parmCountry();

partyAddressView.initFromPostalAddress(logisticsPostalAddress);
partyAddressView.LocationName = f3PostalAddressDocument.parmName();

postalAddressEntity = LogisticsPostalAddressEntity::construct();

addressView.initFromPartyPostalAddressView(partyAddressView);
logisticsPostalAddress = postalAddressEntity.createPostalAddress(addressView);

return logisticsPostalAddress.RecId;

}

 

This function will create records in the table and returns the RecId of LogisticsPostalAddress. Now you have to insert this id in the SalesTable, so it will create relation between SalesTable and LogisticsPostalAddress.

f3PostalAddressService = new F3ComAxPostalAddressService();
salesTable.DeliveryPostalAddress = f3PostalAddressService.createOneTimeAddress(f3PostalAddressDocument);

 

This will create the postal address for that specific sales order and this address will not be added in the address book of the customer.

Share

Muhammad Saqib

Leave a Reply

Your email address will not be published. Required fields are marked *

Latest From Our Blog
Difference between Dynamics CRM and the Dynamic...
Record a Purchase Invoice In Dynamics AX
November 28, 2019
Read more
7 Ways Dynamics 365 Finance and Operations Boos...
dynamics 365 finance
November 9, 2018
Introduction Launched by Microsoft, Dynamics 365 ERP is one of the most effective for businesses today. It is perfect to save the time, effort and ...
Read more
The Ultimate Guide to Dynamics 365 HR Payroll P...
dynamics hr payroll
October 30, 2018
For any business, irrespective of its size, payroll processing is one of the most important functions. Payroll processing is a method through which...
Read more
Contact Form