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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Data entity import problem with mandatory field

(3) ShareShare
ReportReport
Posted on by 1,274
Hello,
 
I have a custom data entity where there are 2 datasources that are related to each other by transactionid and joined by innerjoin.

 
I'd like the transaction id to be generated when inserting the line via DMF. I need the parent and chold tabled to have the same transactionid generated. I added this code to the entity

 
when Importing data via DMF I always get this error

 
could you please point me to the right direction?
 
Thank you.
Categories:
I have the same question (0)
  • RSy Profile Picture
    148 on at
    Hi,

    Is the mapping details marked as auto generated for that id?
  • dark_knight Profile Picture
    1,274 on at
    Hello,

    Where to check this?
  • Saalim Ansari Profile Picture
    708 on at

    Hi,

    A couple of things you can check: 

    1. Verify if the TransactionId is set to auto-generate in your table setup/number sequence. If it’s not, DMF will try to insert NULL and fail.
    2. For testing, try handling only the parent datasource first.
      • Keep the case for SalesCRMTransactionTable with the TransactionId generation.
      • Comment out the case for SalesCRMTransactionStatus.
      • Import via DMF and see if the header record gets created correctly.
    3. Next, uncomment the child case and simply assign the stored variable to the child’s TransactionId.
     
    str transactionId = NumberSeq::newGetNum(smmParametersTable::numRefCRMIntegrationId());
    statusTable.TransactionId = transactionId; 
     

    This way you’ll know if the issue is with ID generation itself or just with propagating it to the child table.

    Hope it helps ;) and let me know if you need more help!
    Saalim.

  • Martin Dráb Profile Picture
    239,451 Most Valuable Professional on at
    I don't think that your code runs at all. According to the error message, it fails already when trying to write record to the staging table, while your code would run when applying the staging data to actual F&O tables.
     
    My guess is that TransactionId is mandatory in the staging table while you don't have any value in the import file. You need to either make the field optional (and use something else to identify records) or you need to provide a value. For new records, it could be a dummy value that you'll then overwrite with a new value from number sequence.
     
    The framework has a support for auto-generated values. The configuration is in the source mapping of your import project. Click the View map icon 
    which opens Map source to staging form. Switch to Mapping details tab and notice the Auto-generated option.
    You'll still need to code tell the system which number sequence to use.
  • Suggested answer
    DAnny3211 Profile Picture
    11,421 Super User 2026 Season 1 on at

    Hi,

     

    The error you're encountering—"The column TRANSACTIONID in entity Sales CRM Transaction Table has incorrect data"—suggests that the TransactionId is either not being generated correctly or not being passed consistently between the parent and child data sources during the DMF import.

     

    Key Observations

     

    • You're using insertEntityDataSource() to generate the TransactionId for the parent (SalesCRMTransactionTable_XXX) and assign it to the child (SalesCRMTransactionStatus_XXX).

    • However, the child entity is likely receiving a null or uninitialized TransactionId, which causes the import to fail.


    •  
     

    Recommended Fixes

     

    1. Store the generated TransactionId in a class-level variable:
      Ensure that the TransactionId generated in the parent is stored and reused for the child. For example:

       

       

      private str generatedTransactionId;
      
      public boolean insertEntityDataSource(DataEntityRuntimeContext _entityCtx, DataEntityDataSourceRuntimeContext _dataSourceCtx)
      {
          switch (_dataSourceCtx.name())
          {
              case dataentitydatasourcestr(SalesCRMTransactionEntity SalesCRMTransactionTable_XXX):
                  headerLine = _dataSourceCtx.getBuffer();
                  generatedTransactionId = NumberSeq::newGetNum(smmParametersTable::numRefCRMIntegration);
                  headerLine.TransactionId = generatedTransactionId;
                  headerLine.TransactionDate = DateTimeUtil::utcNow();
                  break;
      
              case dataentitydatasourcestr(SalesCRMTransactionEntity SalesCRMTransactionStatus_XXX):
                  statusTable = _dataSourceCtx.getBuffer();
                  statusTable.retrycount = 0;
                  statusTable.TransactionId = generatedTransactionId;
                  break;
          }
      
          return super(_entityCtx, _dataSourceCtx);
      }
      

       


    2. Validate the sequence setup:
      Make sure smmParametersTable::numRefCRMIntegration is correctly configured and active.


    3. Check the data entity relationships:
      Confirm that the inner join between the parent and child is correctly defined in the data entity and that the TransactionId is marked as a key field in both.


    4. Test with a small dataset:
      Try importing a minimal set of records to verify that the TransactionId is correctly generated and propagated.



    5.  
     

    This approach should ensure that both tables receive the same TransactionId during import, resolving the staging error.

     

    Thanks and best regards,\
    Daniele\
    Note: This response was prepared with support from Copilot to ensure clarity and completeness.

  • dark_knight Profile Picture
    1,274 on at
    Hi Martin,
     
    I moved my code to the mapentitytodatasource. Also I choose skip staging so staging table can't be the cause of the problem here as far as I understand.
    symbols are not loaded for some reason so I cannot debug while importing
     
     
  • Martin Dráb Profile Picture
    239,451 Most Valuable Professional on at
    Look at your screenshot. It shows the failing stage is Source; the Target phase (where your code would run) isn't run at all.  You can also use the debugger to see whether your code runs as all.
     
    You're wrong about skip staging. It doesn't mean that the stage of Source stage disappears.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 608

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 591 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 430

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans