web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Answered

Customer address and phone not showing in UI after X++ insert in D365 FO

(0) ShareShare
ReportReport
Posted on by 137

Problem:
I am creating a customer programmatically using X++ in Dynamics 365 Finance and Operations. I insert the address into LogisticsPostalAddress and the phone into LogisticsElectronicAddress. I also link the location to the Party using DirParty::addLocation() with the correct roles (Delivery, Business, Invoice).

 

What happens:

  • The customer is created successfully

  • The address and phone records are inserted successfully in the database

  • When I check the tables directly, all data exists and is correctly linked

  • But when I open the customer in the UI, the Addresses tab is empty and the Contact information tab is empty

What should happen:
After inserting address and phone data via X++, the customer should display the address under the Addresses tab and the phone under the Contact information tab, just like when adding manually through the UI.

Note:

  • Manual entry through the UI works fine

  • The problem only happens with programmatic insertion

Question:
Is there a missing step in my code? Do I need to refresh something or update the cache after inserting? Any help would be appreciated.

I have the same question (0)
  • Mohamed Amine Mahmoudi Profile Picture
    26,803 Super User 2026 Season 1 on at
     
    Can you please share with us your x++ code ?
     
    BR
  • André Arnaud de Calavon Profile Picture
    304,729 Super User 2026 Season 1 on at
    Hi Rami,

    Please share us the code you are using. After adding the location, did you link the correct reference to the location on the logistics postal address and electronic address?
     
  • Verified answer
    Rami Mazrawi  * Profile Picture
    137 on at
    Thank you so much, Mr. (  ) and Mr. (  ). I tried, found the solution, and it worked... Thank you always for your continued support. This is the solution:
     
    // إنشاء العنوان
    if (Data.parmCity() || Data.parmAddressDetail() || Data.parmBuildingNumber() || Data.parmDistrict())
    {
        DirPartyPostalAddressView  postalAddressView;
        DirPartyLocation           partyLocationLocal;
        DirPartyLocationRole       partyLocationRole;
        LogisticsLocationRole      locationRole;
        LogisticsAddressCountryRegion countryRegion;
        CompanyInfo                companyInfo;
        RecId                      locationRecId;
        str                        street = '';
        // الحصول على شركة العميل
        companyInfo = CompanyInfo::find();
        if (companyInfo.DataArea != Data.parmCompany())
        {
            select firstonly companyInfo
            where companyInfo.DataArea == Data.parmCompany();
        }
        // بناء الشارع
        if (Data.parmAddressDetail())
        {
            street = Data.parmAddressDetail();
        }
        if (Data.parmBuildingNumber())
        {
            street = street ? strFmt("%1, %2", street, Data.parmBuildingNumber()) : Data.parmBuildingNumber();
        }
        if (Data.parmDistrict() && Data.parmDistrict() != 'NA')
        {
            street = street ? strFmt("%1, %2", street, Data.parmDistrict()) : Data.parmDistrict();
        }
        street = strLRTrim(street);
        // الحصول على الدولة الافتراضية
        select firstonly countryRegion;
        // تجهيز PostalAddressView
        postalAddressView.clear();
        postalAddressView.initValue();
        postalAddressView.Street = street;
        postalAddressView.City = Data.parmCity();
        postalAddressView.IsPrimary = NoYes::Yes;
        if (countryRegion.RecId)
        {
            postalAddressView.CountryRegionId = countryRegion.CountryRegionId;
        }
        // إنشاء العنوان
        dirParty.createOrUpdatePostalAddress(postalAddressView);
        debugStep = "16. Address created";
        // البحث عن PartyLocation
        select firstonly partyLocationLocal
        where partyLocationLocal.Party == custTable.Party
           && partyLocationLocal.IsPrimary == NoYes::Yes
           && partyLocationLocal.IsPostalAddress == NoYes::Yes;
        if (partyLocationLocal.RecId)
        {
            // إضافة الأدوار
            locationRole = LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Delivery);
            if (locationRole.RecId)
            {
                select firstonly partyLocationRole
                where partyLocationRole.PartyLocation == partyLocationLocal.RecId
                   && partyLocationRole.LocationRole == locationRole.RecId;
                if (!partyLocationRole.RecId)
                {
                    partyLocationRole.clear();
                    partyLocationRole.initValue();
                    partyLocationRole.PartyLocation = partyLocationLocal.RecId;
                    partyLocationRole.LocationRole = locationRole.RecId;
                    partyLocationRole.insert();
                }
            }
            locationRole = LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Invoice);
            if (locationRole.RecId)
            {
                select firstonly partyLocationRole
                where partyLocationRole.PartyLocation == partyLocationLocal.RecId
                   && partyLocationRole.LocationRole == locationRole.RecId;
                if (!partyLocationRole.RecId)
                {
                    partyLocationRole.clear();
                    partyLocationRole.initValue();
                    partyLocationRole.PartyLocation = partyLocationLocal.RecId;
                    partyLocationRole.LocationRole = locationRole.RecId;
                    partyLocationRole.insert();
                }
            }
            locationRole = LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Business);
            if (locationRole.RecId)
            {
                select firstonly partyLocationRole
                where partyLocationRole.PartyLocation == partyLocationLocal.RecId
                   && partyLocationRole.LocationRole == locationRole.RecId;
                if (!partyLocationRole.RecId)
                {
                    partyLocationRole.clear();
                    partyLocationRole.initValue();
                    partyLocationRole.PartyLocation = partyLocationLocal.RecId;
                    partyLocationRole.LocationRole = locationRole.RecId;
                    partyLocationRole.insert();
                }
            }
            debugStep = "17. Address roles added";
        }
    }

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 130 Super User 2026 Season 1

#2
Laurens vd Tang Profile Picture

Laurens vd Tang 92 Super User 2026 Season 1

#3
Zain Mehmood Profile Picture

Zain Mehmood 89 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans