January 23, 2011

No such column on entity error and connections with FLS !

One friend (lets call him Ram) of mine was developing an SFDC integration using Java API. His integration authorizes multiple sfdc users and performs some SOQL calls for business logic on Sobjects like Event.

Application was going pretty well, until one day it crashed for this error

Description,Subject,IsAllDayEvent,DurationInMinutes ^ ERROR at Row:1:Column:48 No such column 'IsAllDayEvent' on entity 'Event'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. - InvalidFieldFault

Ram was surprised to see this ! Because

  • “IsAllDayEvent” is a standard Event object field
  • He can see the field in SOQL Browser and
  • Of course on Event field details page(Setup > Customize > Activities > Event Fields > Field Detail page). 
  • He can also created all day events in Salesforce.

So, why this error came ?

This error came because of “Field Level Security” issue. The user hitting the Java application was on a different SFDC Profile from Ram. Ram was system administrator with super powerful set of permissions. But the user troubled with this error was on a different profile. This profile was not having the required access permissions for this event field, so Salesforce throwed this “No Such Column…” error on making a SOQL call.

Its wired and confusing error message isn’t, the column was actually there, but its just a permission issue. It should be changed to more insightful to say “Field X you are trying to query is not visible to your profile

Solution

Its easy, just ensure visibility on FLS(Field Level Security) page for all queried fields. You can see visibility of a Sobject field per profile, by visiting its FLS page.

For this Event case, Goto 

"Setup > Customize > Activities > Event Fields > Field Detail page >  IsAllDayEvent > Set Field-Level Security Page"

On this page, ensure that visible checkbox is turned on for all required SFDC Profiles. For more details, please check screen shot below

image

Suggestions !

One should always consider to detail about field level security in release notes or user manual for the SFDC App. This FLS detail should include, what at minimum FLS access is required for your application to run smoothly. So identify all Sobject/Fields/Metadata you are accessing and all the target user profiles, ensure mention about the required level of access edit/read for each.

References

”No Such column error “ might come because of polymorphic keys, so if above story doesn’t solves your problem check this post for more details on troubleshooting the same error for polymorphic keys.