The field with ID '0' does not exist in table - Cause and resolution.
Hello readers,
In Dynamics AX coding, you should have come across this error sometime - The field with ID '0' does not exist in table 'SomeTable'
So what causes this error and what is the possible resolution to it?
Well, the most likely cause for this error is a missing mapping in a table map.
Let us look at an example.
I've a simple Map named CustVendAccount with one Account field. I've created two mappings - one with CustTable's AccountNum field and for the otehr mapping, I just specify VendTable but no field.
This is how my map looks like,
Now, I've a simple job which just passes either CustTable or VendTable as an argument and then we print the Account field in the map.
If you run the job, you will get a run time error and the debugger will break at line 8 with this error.
As you can see from the image, the error says that The field with ID '0' does not exist in table 'VendTable'
In our CustVendAccount map, we didn't map the Account field with any field from the VendTable table. Because of this misssing mapping, the field has an ID of zero and an error is thrown.
So the next time, you hit this error, check your field mapping in your map. This should save you a lot of time.
I hope this post was useful.
Thats all for today, check back soon.
In Dynamics AX coding, you should have come across this error sometime - The field with ID '0' does not exist in table 'SomeTable'
So what causes this error and what is the possible resolution to it?
Well, the most likely cause for this error is a missing mapping in a table map.
Let us look at an example.
I've a simple Map named CustVendAccount with one Account field. I've created two mappings - one with CustTable's AccountNum field and for the otehr mapping, I just specify VendTable but no field.
This is how my map looks like,
Now, I've a simple job which just passes either CustTable or VendTable as an argument and then we print the Account field in the map.
static void CustVendAccountMap(Args _args) { CustTable custTable; VendTable vendTable; void readMap(CustVendAccount _custVendAccount) { info(strFmt("Value from table %1 is %2",tableId2name(_custVendAccount.TableId), _custVendAccount.Account)); } select firstOnly custTable; select firstOnly vendTable; readMap(custTable); readMap(vendTable); pause; }
If you run the job, you will get a run time error and the debugger will break at line 8 with this error.
As you can see from the image, the error says that The field with ID '0' does not exist in table 'VendTable'
In our CustVendAccount map, we didn't map the Account field with any field from the VendTable table. Because of this misssing mapping, the field has an ID of zero and an error is thrown.
So the next time, you hit this error, check your field mapping in your map. This should save you a lot of time.
I hope this post was useful.
Thats all for today, check back soon.
Comments