web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

An error ocurred when trying to export an entity

(0) ShareShare
ReportReport
Posted on by 1,915

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

I have the same question (0)
  • Suggested answer
    Alireza Eshaghzadeh Profile Picture
    14,637 Super User 2025 Season 2 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?

  • André Arnaud de Calavon Profile Picture
    299,883 Super User 2025 Season 2 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.

  • .. Profile Picture
    1,915 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
    299,883 Super User 2025 Season 2 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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 756 Super User 2025 Season 2

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 678

#3
Martin Dráb Profile Picture

Martin Dráb 526 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans