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

There is mismatch between source and target fields for insert_Recordset

(0) ShareShare
ReportReport
Posted on by 5

I have been using insert_recordset approach but sometimes because of the query and mapping I face this issue.

Not sure how to handle this, previously when I faced this issue I just change the sequences of the datasources in my query and is got resolved but that query was having multiple child datasources in a single paren but now this is not the case.

Below is the source code im using.

final protected void buildFieldMap(Query _reportQuery, Map _fieldMap)
{
QueryBuildDataSource taxAuthorityAddressDS = _reportQuery.dataSourceTable(tableNum(TaxAuthorityAddress));
QueryBuildDataSource taxTransDS = _reportQuery.dataSourceTable(tableNum(TaxTrans));
QueryBuildDataSource taxTableDS = _reportQuery.dataSourceTable(tableNum(TaxTable));

_reportQuery.clearAllFields();

// Tax Authority Address fields
int taxAuthorityAddressUniqueId = taxAuthorityAddressDS.uniqueId();
QueryBuildFieldList taxAuthorityAddressFL = taxAuthorityAddressDS.fields();

taxAuthorityAddressFL.addField(fieldNum(TaxAuthorityAddress, TaxAuthority));
_fieldMap.insert(fieldStr(KGPSalesTaxCollectedSummaryTmp, TaxAuthority), [taxAuthorityAddressUniqueId, fieldStr(TaxAuthorityAddress, TaxAuthority)]);

taxAuthorityAddressFL.addField(fieldNum(TaxAuthorityAddress, Name));
_fieldMap.insert(fieldStr(KGPSalesTaxCollectedSummaryTmp, TaxAuthorityName), [taxAuthorityAddressUniqueId, fieldStr(TaxAuthorityAddress, Name)]);

// Tax Trans fields
int taxTransUniqueId = taxTransDS.uniqueId();
QueryBuildFieldList taxTransFL = taxTransDS.fields();

taxTransFL.addField(fieldNum(TaxTrans, ExemptTax));
_fieldMap.insert(fieldStr(KGPSalesTaxCollectedSummaryTmp, ExemptTax), [taxTransUniqueId, fieldStr(TaxTrans, ExemptTax)]);

taxTransFL.addField(fieldNum(TaxTrans, TaxAmountCur));
_fieldMap.insert(fieldStr(KGPSalesTaxCollectedSummaryTmp, TaxAmountCur), [taxTransUniqueId, fieldStr(TaxTrans, TaxAmountCur)]);

taxTransFL.addField(fieldNum(TaxTrans, TaxBaseAmountCur));
_fieldMap.insert(fieldStr(KGPSalesTaxCollectedSummaryTmp, TaxBaseAmountCur), [taxTransUniqueId, fieldStr(TaxTrans, TaxBaseAmountCur)]);

taxTransFL.addField(fieldNum(TaxTrans, TaxDirection));
_fieldMap.insert(fieldStr(KGPSalesTaxCollectedSummaryTmp, TaxDirection), [taxTransUniqueId, fieldStr(TaxTrans, TaxDirection)]);

int taxTableUniqueId = taxTableDS.uniqueId();
QueryBuildFieldList taxTableFL = taxTableDS.fields();

taxTableFL.addField(fieldNum(TaxTable, TaxPackagingSort));
_fieldMap.insert(fieldStr(KGPSalesTaxCollectedSummaryTmp, TaxPackagingSort), [taxTransUniqueId, fieldStr(TaxTable, TaxPackagingSort)]);



Query::insert_recordset(salesTaxCollectedSummaryTmp_taxAuth, _fieldMap, _reportQuery);

}

below is the query and the map I'm getting.

SELECT TaxAuthority, Name FROM TaxAuthorityAddress(TaxAuthorityAddress) 
JOIN  FROM TaxPeriodHead(TaxPeriodHead) ON TaxAuthorityAddress.TaxAuthority = TaxPeriodHead.TaxAuthority 
JOIN ExemptTax, TaxAmountCur, TaxBaseAmountCur, TaxDirection 
FROM TaxTrans(TaxTrans) ON TaxPeriodHead.TaxPeriod = TaxTrans.TaxPeriod 
AND ((TransDate>={ts '2021-01-01 00:00:00.000'} AND TransDate<={ts '2021-09-30 00:00:00.000'})) 
JOIN TaxPackagingSort FROM TaxTable(TaxTable) ON TaxTrans.TaxCode = TaxTable.TaxCode

{["ExemptTax"-><2>,"TaxAmountCur"-><2>,"TaxAuthority"-><2>,"TaxAuthorityName"-><2>,"TaxBaseAmountCur"-><2>,"TaxDirection"-><2>,"TaxPackagingSort"-><2>}

As you see above the sequences are not matching.
Please help me resolve this issue. Thanks in advance.

I have the same question (0)
  • Suggested answer
    Suresh M. Parmar Profile Picture
    340 on at

    Hello Rizwan,

    There is the code correction, find below SS for reference.

    Use taxTableUniqueId instead of taxTransUniqueId.

    pastedimage1634031525104v1.png

    Thanks,

    Suresh Parmar

    Please mark verified if you get the solution.

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 692

#2
André Arnaud de Calavon Profile Picture

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

#3
CP04-islander Profile Picture

CP04-islander 478

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans