SBX - Search With Button

SBX - Forum Post Title

Field "fieldname" in Table "tablename" has not been explicitly selected in AX 2012

Microsoft Dynamics AX Forum

Giuseppe Caradonna asked a question on 10 May 2013 3:23 AM
My Badges

Question Status

Verified

Hi all,

I've a Dynamics AX 2012 installation in my enviroment. When I open several forms (like Target Entities in Data Import Export Framework, or CustTrans, or VendTrans) I receive this error: Field "fieldname" in Table "tablename"  has not been explicitly selected in AX 2012.

Can you tell me what can be the cause of this error?

Reply
Petr Janík responded on 11 May 2013 10:31 AM
My Badges

Hi Guiseppe,

I have seen this error a few times. It can be caused by an illegal data in a table , e.g. it contains NULL value, which is not allowed in AX (except table inheritance). Sometimes it helps me to restart a client or AOS. Of course I assumed that you did full compile without errors and synchronized the database.

Reply
Giuseppe Caradonna responded on 13 May 2013 12:14 AM
My Badges

Hi Petr,

Unfortunately I have already compiled and synchronized the application without errors and restarted the AOS...Any other ideas?

Reply

It means that the field was read but its value wasn't retrieved from database. See Tutorial: AX 2012 - Invalid field access or Accessing unretrieved fields for more detailed explanation.

Reply
Petr Janík responded on 13 May 2013 1:05 AM
My Badges

You are right Martin, but this is true if you select existing record from a table. In this case is evident that the user open the form DMFEntity for the first time. So, the table DMFEntity is empty and the init method of the DMFEntity form wants to populate this table with default mapping and calls the validateWrite method before insert.

Reply
Giuseppe Caradonna responded on 14 May 2013 1:11 AM
My Badges

Petr, is it a bug?

Reply
J. Pospisil responded on 16 May 2013 8:02 AM

Hi,

I have the some problem with AX 2012R2:

This is the error msg when I run Sales Tax Report:

Stack trace: Field 'VATNum' in table 'CompanyInfo' has not been explicitly selected.

Stack trace

(S)\Classes\TaxReportingDP\insertTaxReportingTmp - line 82

(S)\Classes\TaxReportingDP\processReport - line 101

(S)\Classes\SrsReportProviderQueryBuilder\initialize - line 57

(S)\Jobs\

Stack trace error appears also - for example - when I export data from the database.

Can somebody help me, please?

thx!

Reply
Gustavo Silva responded on 16 May 2013 8:10 AM
My Badges

I believe the original "select" is using a Field List, and the field DMFEntity is probably not in the field list, or for some other reason (aggregate functions maybe) the field may be not retrieved.

There is no problem on calling validateWrite before Insert. It's actually a good practive, but if the validateWrite is overridden in the Form Datasource, then there might be a need for a technical intervention.

Check that.

Reply
Giuseppe Caradonna responded on 16 May 2013 8:48 AM
My Badges

I get the same error in other places...CustTrans table --> postLoad() method, VendTrans table --> postLoad() method...What can I do to fix it?

Reply
Giuseppe Caradonna responded on 22 May 2013 1:38 AM
My Badges
Verified Answer

Hi all,

I'm receiving this error in some other methods in AX. I am solving by changing the select statements adding the required field.

Reply
Kim Lee responded on 3 Jul 2013 10:14 PM

What do you mean by "changing the select statements adding the required field"?

Reply
Bella N responded on 11 Jul 2013 3:15 AM

Hi Giuseppe,

I encountered the same error also "Field 'isConsolidation' in "CompanyInfo' has not been explicitly selected".

How do you resolve the issue? Where do you do the select statement?

Thank you.

Reply
pvanstipelen responded on 30 Jul 2013 1:50 AM
My Badges

I added a blog post about this matter. I hope this helps!

Always check the datasource/select statement for the error

pvsax.wordpress.com/.../field-has-not-been-explicity-selected

Kind regards,

Philippe

Reply
____-__-__ responded on 2 Aug 2013 12:18 AM

System administration - setup - system - server configuration

tab: performance optimization

"Error on invalid field access" => set to "no"

Reply
Oleg Abapolov responded on 20 Nov 2013 2:28 AM
My Badges
Suggested Answer

Hi,

For new fields in CompanyInfo the solution was to "compile forward" from DirPartyTable.

Reply
Giuseppe Caradonna responded on 22 May 2013 1:38 AM
My Badges
Verified Answer

Hi all,

I'm receiving this error in some other methods in AX. I am solving by changing the select statements adding the required field.

Reply
Rob Hensley responded on 30 Jul 2014 8:22 AM
My Badges
Verified Answer

Go to the System Administration module -> Setup -> System -> Server Configuration.

On this form, under the Performance Optimization fast tab on the right, look for the "Error on invalid field access" setting.  Unfortunately, if you set this to Yes you will see lots of these errors in the base AX code.  Change this value to No and you should no longer get these error messages.

The previous suggestions are correct, this is caused by a field not being selected in a select statement, query, etc and then trying to be read.

Reply
Oleg Abapolov responded on 20 Nov 2013 2:28 AM
My Badges
Suggested Answer

Hi,

For new fields in CompanyInfo the solution was to "compile forward" from DirPartyTable.

Reply
JohanOrn responded on 17 Sep 2015 6:35 AM
Suggested Answer

Hi,

We had the same error, it was actually the coding that had been done, the developer had done a select sum(field) group by field1, field2.

But then below he tried to use other fields, so from the same table he tried to use field3 and field4, but since it had never been selected from the select statement, it was NULL. And then it threw the stack trace first on field3, then when i added that to the select statement it threw an error on field4 instead.

These 2 fields were not needed, so i just removed them and now it works fine again.

Reply

SBX - Two Col Forum

SBX - Migrated JS