Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

Create or Update Customer Address through code X++ in D365 F&O

Posted on by 742

Hi Everyone,

With below code I am able to create address on Customer. But I want to  set the Purpose as well.

Can anyone help me to modify my code? How can I pass parameter for setting purpose of Address that is, Business/Delivery/Invoice .. etc.

 private void createAddress(SIAddressParameter			_address,
                              SICustomerAddressParameter	_custAddressParam,
                              CustTable						custTable)
    {
        dirPartyPostalAddressView     dirPartyPostalAddressView;
        DirParty                      dirparty;

        dirParty = DirParty::constructFromCommon(custTable);
   
        dirPartyPostalAddressView.LocationName          = _address.parmAddlocationName();
        dirPartyPostalAddressView.City                  = _address.parmCity();
        dirPartyPostalAddressView.Street                = _address.parmStreet();
        dirPartyPostalAddressView.CountryRegionId       = _address.parmCountryId();
        dirPartyPostalAddressView.State                 = _address.parmState();
        dirPartyPostalAddressView.zipcode               = _address.parmZipCode();
        dirPartyPostalAddressView.IsPrimary             = (_address.parmShipto())?NoYes::Yes:NoYes::No;
        dirPartyPostalAddressView.FSWithinCityLimits    = (_address.parmWithinCity() == 'Yes')?NoYes::Yes:NoYes::No;
        dirPartyPostalAddressView.FSYearBuilt           = _address.parmYearBuilt();
        dirPartyPostalAddressView.FSLeadPaintStatusId   = _address.parmLeadPaintStatusId();
        dirPartyPostalAddressView.CHI_CRMAddressId      = _address.parmCRMAddressId();
  
        dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView,str2con(_address.parmAddRoles()));
    }

Add01.png

  • Rhushikesh R Profile Picture
    Rhushikesh R 742 on at
    RE: Create or Update Customer Address through code X++ in D365 F&O

    Thanks Will for prompt response.

  • Verified answer
    WillWU Profile Picture
    WillWU 22,350 on at
    RE: Create or Update Customer Address through code X++ in D365 F&O

    Hi Rhushikesh,

    Please try to add:

    container roles;
    roles = LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Invoice).RecId;
    dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView, roles);

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,113 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,918 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans