Skip to main content

Notifications

Announcements

No record found.

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

An error ocurred when trying to export an entity

(0) ShareShare
ReportReport
Posted on by 1,333

Hi,

I created a batch job that exports an entity by code

There is an error in the batch which is

--Object query could not be created

--Bad container 

--An error occured when trying to export the entity

**I can't debug as this is prod

What could cause such error

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 292,234 Super User 2025 Season 1 on at
    RE: An error ocurred when trying to export an entity

    Hi Integration beginner,

    As this might be related to custom coding, I would suggest to use the debugger to find out on what line the error is raised. Then you can check what needs to be changed.

    In your coding you filled the optional parameters of the exportToFile method. You can try to remove the last two parameters. Then the method will use default values for it.

  • .. Profile Picture
    .. 1,333 on at
    RE: An error ocurred when trying to export an entity

    Hi Alireza and Andre,

    It's a custom composite entity, that I export by code then send to to azure blob

    so what happens is, that everytime a journal is posted, I export the entity, where I update the status of a log table to try and replace change tracking

    It fails at the export. Could it be because of the number of users who are posting a journal at the same time? or is it related to the executionId? as this doesn't happen in my dev machine

      DictCompositeDataEntity compositeDataEntity = new DictCompositeDataEntity(_queryName);
                entityName = compositeDataEntity.label();
                compositeDataEntity.label();
    
                // Start:Optional if you want to filter data while exporting
                Query                query = new Query(DMFUtil::getDefaultQueryForEntityV3(entityName,_definitionGroupName));
    
                DMFEntityExporter exporter = new DMFEntityExporter();
                fileId = exporter.exportToFile(
                                            entityName,
                                            _definitionGroupName,
                                            DMFUtil::generateExecutionId(_definitionGroupName), //Optional: ExecutionID
                                            _dmfSourceName, //Optional::SourceName
                                            #FieldGroupName_AllFields, //Optional field selection
                                            query.pack(), //Optional: Filtered Query
                                            curExt() //Optional: DataAReaId
                                            );
    



    pastedimage1636359349041v1.png


    When I tried to export it as XML in Live. I got this warning when I added the entity:
    entity doesn't have primary or unique key staging table needs to be altered
    what is this one? 
    However,  when I exported the entity, it succeeded and I was able to see the file. However, there was a failing child entity because of an existing record, but this didn't affect the export

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 292,234 Super User 2025 Season 1 on at
    RE: An error ocurred when trying to export an entity

    Hi IntegrationBeginner,

    Like Alireza mentioned, try to export it to Excel or XML using the Data management framework.

    Can you provide information if you are exporting from a standard or custom data entity?

    Note that you can debug in other environments. You can setup an environment with the same code base and database as the production environment. Then you can start debugging.

  • Suggested answer
    Alireza Eshaghzadeh Profile Picture
    Alireza Eshaghzadeh 13,564 Super User 2025 Season 1 on at
    RE: An error ocurred when trying to export an entity

    Hi IntegrationBeginner,

    Can you elaborate more about which entity and the export batch job ?

    Have you tried to export the entity via DMF to excel to check if you get the same error message?

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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,234 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,994 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans