Skip to main content

Notifications

Announcements

No record found.

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

Data Entity set the Reference (RecId) on datasource

Posted on by 6,414
Hello,
there is a standard data entity for Planned Orders (ReqPlannedOrderEntity), which is read-only and we wanted to change it.
I have duplicated it and set Read-Only to No.
I have removed some datasources too and currently I keep only ReqPo and InventDim.
The Key on datasource and on table ReqPo is a PlannedOrderID (RefId) and PlanVersion (RefRecId to ReqPlanVersion table).
I have a unmapped str field on data entity which during the export is filled by the PlanVersion Id in the postLoad method.
But I have problem during the Import. Even though I have value in the PlanVersionId field in Excel, when I import it I do not see the value (during debugging) in any of the following methods (mapEntityToDataSource, mapDataSourceToEntity, postLoad). And I'm getting error that the Reference isn't set (because of the PlanVersion field, which is refRecId).
How can I achieve it? Which method can I use?
So, I have a value in excel column and this column/field is mapped to an /UnMapped/ field of Data entity / staging table. And I want to use this value (which is the plan version id) to find a recid of ReqPlanVersion table.
  • Johnny Profile Picture
    Johnny 6,414 on at
    Data Entity set the Reference (RecId) on datasource
    As I see ValidateWrite is executed first and it thrwos error that Reference isn't set, so it does not even go to mapEntityToDataSource where I assign value to "Reference" field.
    So, what would be a place place to place the code?
  • Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,605 Super User 2024 Season 1 on at
    Data Entity set the Reference (RecId) on datasource
    Please send your code which you have written in mapentitytodatasource method. 
  • Suggested answer
    Anthony Blake Profile Picture
    Anthony Blake 2,184 Super User 2024 Season 2 on at
    Data Entity set the Reference (RecId) on datasource
    Take a look here:
     
     
    There are a few options:
     
    Handle creation manually from unmapped field using mapEntityToDataSource 
    Create the data entity from scratch using the wizard
    Take a look at how some standard entities handle the same situation, there al lots of RefRecId references in standard code.

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans