Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

How to handle RefRecIds in custom data entity?

Posted on by 155
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
    Sukrut Parab 71,645 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
    André Arnaud de Cal... 290,900 Super User 2024 Season 2 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
    Arif Hussain 155 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
    Navneeth Nagrajan 1,434 Super User 2024 Season 2 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
    André Arnaud de Cal... 290,900 Super User 2024 Season 2 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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

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... 290,900 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,275 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans