Total Pageviews

Search This Blog

Wednesday, October 26, 2011

Error executing code: The field with id 0 does not exist in table

Had been busy past couple of days as was involved in writing a complex API which looks onto the Inventory Cost Breakdown tree and writes the data into a custom table after doing some transformation of data on the go.

As I was developing, I bumped into this run time error:

Error executing code: The field with id 0 does not exist in table



















Investigation:

As usual, I googled about this error and came across this blogpost here http://daxline.blogspot.com/2011/08/field-with-id-0-does-not-exist-in-table.html, It's the exact error but the circumstances were different, It talks about the missing field in map whereas in my case I was not using any Maps.


Solution:

It didn't took me long to troubleshoot the issue as I figured out that the table buffer was getting populated incorrectly, meaning I was inheriting the standard AX InventSettlementTreeNodeCalc class for my API and internally, it was calling a method for calculating the adjustments which I didn't require at that stage in the process, and this adjustment call was populating the settlement table buffer and returning it to Inventtrans table buffer thereby giving a run-time error.

Corrected the table buffers and removed the extra call to calculate adjustments as I was doing it towards the end of the process in a separate routine,


3 comments:

Anonymous said...

Before executing the code, run this check if you do not want to, or can't add a fielmapping:

public boolean isFieldMapped(tableId _mapTableId, tableId _tableIdToTest, str _fieldName)
{
#AOT
TreeNode treeNode = TreeNode::findNode(#TableMapsPath+'\\' + tableid2name(_mapTableId)+'\\mappings' + '\\' + tableid2name(_tableIdToTest));
return treeNode.AOTfindChild(_fieldName) == null;
}

Anonymous said...

public boolean isFieldMapped(tableId _mapTableId, tableId _tableIdToTest, str _fieldName)
{
#AOT
TreeNode treeNode = TreeNode::findNode(#TableMapsPath+'\\' + tableid2name(_mapTableId)+'\\mappings' + '\\' + tableid2name(_tableIdToTest));
return treeNode.AOTfindChild(_fieldName) == null;
}

DAXDude said...

The link to Zubair's blog was broken but I did find the active link here. It looks like the blog went from <>.blogspot.com<> to a .com domain.

Great article!
http://dynamicsaxspace.com/2011/08/the-field-with-id-0-does-not-exist-in-table-cause-and-resolution/