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
Mitul Patel 38Mitul Patel 38 

Sporadic "Internal Salesforce.com Error" for SOQL using external object

We are seeing sporadic "Internal Salesforce.com Error" for SOQL using an external object. When it works SOQL returns value and I am able to see the results. I am not able to put finger on what is causing this internal error and what it means. Any insight to debug the issue would be really helpful. 

Following is snippet of Debug log - 

6:37:16.0 (15971342)|SOQL_EXECUTE_BEGIN|[42]|Aggregations:0|SELECT Id, start_at__c, end_at__c, Id__c, name__c, canvasId__c FROM courses__x WHERE (canvasId__c = :tmpVar1 AND start_at__c <= TODAY AND end_at__c >= TODAY) ORDER BY end_at__c ASC NULLS FIRST
16:37:16.0 (982620934)|FATAL_ERROR|Internal Salesforce.com Error
16:37:16.0 (982666130)|CODE_UNIT_FINISHED|CBS_CourseController.getCoursesForCurrentUser
16:37:16.0 (987728779)|CODE_UNIT_FINISHED|Aura
Best Answer chosen by Mitul Patel 38
jigarshahjigarshah
Mitul,
  • The query stated in the Debug Log uses NULLS FIRST within the ORDER BY clause. However, as per the Salesforce documentation the NULLS FIRST or NULLS LAST is ignored in an Order By clause of a SOQL query which is used on an External Object.So, you may want to try removing the NULLS FIRST clause from the SOQL.
           https://help.salesforce.com/articleView?id=apex_considerations_soql.htm&type=5
  • Check if the Salesforce User account has the necessary Read permissions on the fields it is trying to access.
Hope this helps.

Please mark this thread as SOLVED and answer as the BEST ANSWER if it helps address your issue.

All Answers

jigarshahjigarshah
Mitul,
  • The query stated in the Debug Log uses NULLS FIRST within the ORDER BY clause. However, as per the Salesforce documentation the NULLS FIRST or NULLS LAST is ignored in an Order By clause of a SOQL query which is used on an External Object.So, you may want to try removing the NULLS FIRST clause from the SOQL.
           https://help.salesforce.com/articleView?id=apex_considerations_soql.htm&type=5
  • Check if the Salesforce User account has the necessary Read permissions on the fields it is trying to access.
Hope this helps.

Please mark this thread as SOLVED and answer as the BEST ANSWER if it helps address your issue.
This was selected as the best answer
Mitul Patel 38Mitul Patel 38
Jigar,
Thanks for your response. Your pointers were helpful. But the real culprit turned out to be something else. 

It turned out that "end_at" is a Date field and results returned from middleware sometimes included " " (Space) and not "" (empty). SF was running into the internal error while converting space to Date. It is taken care by the middleware team and we are not seeing the error now.

Mitul.
 
jigarshahjigarshah
Mitul,

I am glad that your issue is resolved and I could be of assistance. Please mark this thread as SOLVED if your issue stands addressed.