Skip to main content

Notifications

Announcements

No record found.

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

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

(0) ShareShare
ReportReport
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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans