Tuesday 27 August 2019

Get Sales Order Address in dynamics 365 F&O X++

In this example I will be showing you how to get a sales order delivery address using below code.

Here, I'm inserting the data in my contract class to use in my API classes.  Pleases change it according to your requirement.

        logisticsPostalAddress = LogisticsPostalAddress::findRecId(salesTable.DELIVERYPOSTALADDRESS);
        if(logisticsPostalAddress)
        {
            select RecId from logisticsLocation index hint
                LogisticsLocationIdx where logisticsLocation.RecId ==  logisticsPostalAddress.Location;

            select RecId from dirPartyLocation where dirPartyLocation.Location == logisticsLocation.RecId;
            
            SalesAddressContract = new SalesAddressContract();
            SalesAddressContract.parmAddressDescription(logisticsLocation.Description);
            SalesAddressContract.parmDeliveryAddressName(DIRPARTYTABLE::findRec(dirPartyLocation.Party).Name);
            SalesAddressContract.parmAddressStreet(logisticsPostalAddress.Street);
            SalesAddressContract.parmAddressCity(logisticsPostalAddress.City);
            SalesAddressContract.parmAddressState(logisticsPostalAddress.State);
            SalesAddressContract.parmAddressCountryRegionId(logisticsPostalAddress.CountryRegionId);
            SalesAddressContract.parmAddressZipCode(logisticsPostalAddress.ZipCode);
            SalesAddressContract.parmAddressCountryRegionId(logisticsPostalAddress.CountryRegionId);
            SalesAddressContract.parmsunTAFMarkForExtAddressCode(logisticsLocation.ExtAddressCode);// Custom field

            addressList.addEnd(SalesAddressContract);

        }

@Rahul

1 comment:

Adding a newline into a string in C# and X++

Below is the sample code we can use for  adding a newline after every occurrence of "@" symbol in the string in C#   using System...