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 178
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. 
  • Sukrut Parab Profile Picture
    71,682 Moderator on at
    How to handle RefRecIds in custom data entity?
    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.
  • André Arnaud de Calavon Profile Picture
    293,207 Super User 2025 Season 1 on at
    How to handle RefRecIds in custom data entity?
    Hi Arif,
     
    In the CustCustomerV3Entity, there is coding related to filling the AddressLocationID in the methods insertEntityDataSource and updateEntityDataSource.
  • Arif Hussain Profile Picture
    178 on at
    How to handle RefRecIds in custom data entity?
    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
  • Suggested answer
    Navneeth Nagrajan Profile Picture
    1,452 Super User 2025 Season 1 on at
    How to handle RefRecIds in custom data entity?
    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.
     
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    293,207 Super User 2025 Season 1 on at
    How to handle RefRecIds in custom data entity?
    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.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,207 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,923 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans