function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
crop1645crop1645 

System.Exception: Internal Salesforce.com Query Error - Diagnosis / Tentative Conclusion

I have an APEX ControllerExtension class which overrides the Edit button.  To make life easy for me, I use a Dynamic SOQL statement to fetch all columns from the Opportunity sObject so they are available for display in the VF page should I need them

 

That is, I create a SOQL statement of the form:

 

'select field1,field2, ...fieldn from Opportunity where id = :oppId'

 

One of my fieldx is a formula field using this formula:

 

 

'First name Last name= ' & $User.FirstName & ' ' & $User.LastName & BR() &
'User.UserType= ' & TEXT($User.UserType) & BR() &
'UserRole.Name=' & $UserRole.Name & BR() &
'UserRole.PortalType=' & TEXT($UserRole.PortalType) & BR() &
'Profile.LicenseType=' & TEXT($Profile.LicenseType) & BR()

If this fieldx is included in either a dynamic SOQL or static SOQL expression, at run time, when executed from the Partner Portal by a partner Portal user, I get:

 

System.Exception: Internal Salesforce.com Query Error

and not much else.

 

Obviously, there is something this formula field does that messes up the SOQL call -- although the field displays fine on the standard controller user interface detail page (View).

 

I selectively commented out parts of the formula to determine which parts cause the Internal Salesforce.com Query Error

 

TEXT($User.UserType) - If present in the formula field, Internal Salesforce.com Query Error occurs

TEXT($UserRole.PortalType)  - If present in the formula field, Internal Salesforce.com Query Error occurs

 

 

All other expressions in the formula field don't cause an error.

 

I can work around this particular problem but in general, any sObject field should be queryable through SOQL and not depend on the formula expression.  Why it works through the standard controller UI and not through a controller extension SOQl (static or dynamic) is unknown.

 

Hopefully, this will help someone out in the future

 

 

 

 

 

 

 

mike1983mike1983
Unfortunately I think I may know the answer to this. I had a similar issue with Sites. The User object (and a few others) are not available publically so you can only access it from within your org. So if it works if you hit the apex page directly but not the partner portal. Thats why. The way I fixed this was by creating a User_public__C object and writing two triggers that look to each object for differences then updates the other.
GuyClairboisGuyClairbois

I am also now receiving this error message intermittently, on a query that was working perfectly fine before.. It's a normal query in a VisualForce page (not via portal or Sites).

 

Sometimes it works, and somtimes it doesn't. I have the feeling that this error message is a more generic message that will be applied to any query that something does wrong with..