Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Data entity method mapDataSourceToEntity() is not executed

(1) ShareShare
ReportReport
Posted on by 612
Hello,
 
I have extended the entity PdsItemBatchAttributeValueV2Entity. I added mapDataSourceToEntity() to it using COC.
I have virtual fields to treat. postLoad() works fine but I want some logic only in case if I want to export, not import.
 
The debugger is not popped when I had a break point in this method or even the event handler onMapingDatasourceToEntity.
 
Does anyone have an idea of why this is happening?
 
Thank you in advance!
Kind regards
  • Rati Sharabidze Profile Picture
    Rati Sharabidze 612 on at
    Data entity method mapDataSourceToEntity() is not executed
    Maybe a post from somewhere mislead me. postload() works fine.
    Thank you Martin.
  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    Data entity method mapDataSourceToEntity() is not executed
    postLoad() is executed when an entity record is read from database. There you can populate virtual fields before exporting data from F&O. It can't be used for data import, because that would require setting values of underlying table fields, not values of virtual fields.
     
    Can you please explain your exact problem with postLoad()?
     
    As far as I know, mapDataSourceToEntity() indeed isn't called in this scenario and the documentation is right when saying that you should use postLoad().
  • Rati Sharabidze Profile Picture
    Rati Sharabidze 612 on at
    Data entity method mapDataSourceToEntity() is not executed
    Thank you for responding Martin.
    As I know, postLoad() is executed in while exporting and while importing as well.
    I want to give value to virtual fields through x++ only while exporting.
    Therefore, I decided to use mapDataSourceToEntity(). I added it in my extension class.
    The code which was in postLoad() and which was working, did not work there.
    Therefore, I set a break point exactly on the line of "COC's next" and started debugging.
    The debugger was not even popped.
     
    Then I tried the equivalent event handler, copied directly from the entity event list and I had same scenario.
    I think I am missing something but I could not figure out what exactly.
     
    Kind regards
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    Data entity method mapDataSourceToEntity() is not executed
    Can you elaborate your question, please? I don't understand the sentence "I want some logic only in case if I want to export, not import".
     
    If you mean that you want to handle export only, postLoad() is a solution, because it indeed executes only when exporting data from F&O.
     
    If you're actually interested in import to F&O, then you need mapEntityToDataSource() instead of mapDataSourceToEntity().

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans