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

Notifications

Announcements

No record found.

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

Responsible AI policies

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

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 551 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans