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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to handle RefRecIds in custom data entity?

(2) ShareShare
ReportReport
Posted on by 206
Hi experts,

I have created a custom table for storing legal entity and their address. My table include the following fields. 



I have to now create data entity for the above table. Here is the data entity I have tried to create. 





I need to import the data through the following data entity, where the record first insert into the LogisticsLocation table and then into LogisticsPostalAddress and finally the LogisticsLocation table RecId insert into my custom table for storing the address. Kindly, assist me how can I achieve the data import into my custom table.

Currently, when I am importing data it is giving me the following error 'Error(s) occurred while writing entity record d365fo' where I set the LocationId to auto generation in field mapping. 

I have used City, Street, StreetNumber, ZipCode, CountryRegionId from LogisticsPostalAddress datasource. The highlighted field LocationId is from LogisticsLocation datasource. The data entity is exporting correctly. 
I have the same question (0)
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    301,069 Super User 2025 Season 2 on at
    Hi Arif,
     
    In this case, you can have a look at other data entities where addresses are used, like data entities for customers and vendors. There is some coding involved in setting a LocationId if it is not provided in the source file.
    Have a look at e.g. the X++ coding on CustCustomerV3Entity.
  • Suggested answer
    Navneeth Nagrajan Profile Picture
    2,438 Super User 2025 Season 2 on at
    Hi,
     
    Create this field as a virtual field instead and add your code either to the mapEntityToDataSource() or postLoad() method in X++. In postLoad() add code if you have Row version change tracking disabled. Hope this helps. Better to have RefRecIds not directly reference the datasource and instead be referenced through code.
     
  • Arif Hussain Profile Picture
    206 on at
    Hi @Andre Arnaud de Calavon,

    Thank you for your suggestion. I looked into the following entity but could not find the exact solution. If you could please suggest/share any similar code or method name in the suggested entity which can help me to understand handling the record Ids. 

    Regards,
    Arif Hussain
  • André Arnaud de Calavon Profile Picture
    301,069 Super User 2025 Season 2 on at
    Hi Arif,
     
    In the CustCustomerV3Entity, there is coding related to filling the AddressLocationID in the methods insertEntityDataSource and updateEntityDataSource.
  • Sukrut Parab Profile Picture
    71,710 Moderator on at
    If you are importing new addresses, you need to set location ID to auto generate. Did you debug to see what exact error message you are getting ? Standard entity's for customer and vendors as Andre mentioned works similarly. Unless you don't share exact error message you are getting its difficult to provide help.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 592 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 478 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 305 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans