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
penguinatorpenguinator 

Bug using week_in_year(ActivityDate) with Task?

I'm running the following SOQL statement and it always produces an unexpected error:

 

 

select week_in_year(ActivityDate), count(Id)
from Task
group by week_in_year(ActivityDate)

 

 

The error from a previous similar call was: "UNKNOWN_EXCEPTION: An unexpected error occurred. Please include this ErrorId if you contact support: 228937263-10791 (1171053875)"  However, the following code works fine:

 

 

select ActivityDate, count(Id)
from Task
group by ActivityDate

 

Is there something I'm missing or is this a quirk with week_in_year?  I'm using the 18.0 version of the SOAP partner API (https://www.salesforce.com/services/Soap/u/18.0).

 

 

Thanks!

Ispita_NavatarIspita_Navatar

I went through the documentation for Apex API but was not able to zero in on any specific cause which may trigger the error you are getting, but I realized that "ActivityDate" has a dynamic datatype it is of type Date for Tasks and of type DateTime for Events, hence I would suggest you to fire your query in such a way that in one you just fire it on Tasks and in another you run on Events,in case you get error in any one of the set you will get the answer which will be probably datatype mismatch. In case you get error with both data sets , may you can check for null "ActivityDate" which too may be triggering this error.

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.

 

penguinatorpenguinator

Unless I'm missing something, my query is only running against the Task object and not the Event object so there shouldn't be a conflict between the two.  For now, I'm grouping by ActivityDate and not by week_in_year(ActivityDate) so that I avoid this problem.

 

Also, I simplified my query but I do have a where clause in there as: where ActivityDate=THIS_FISCAL_QUARTER which excludes the possibility of any null ActivityDate values.

CurataCurata

I am hitting a similar issue when I put WEEK_IN_YEAR(ActivityDate) in the SELECT clause of a GROUP BY Query:

field ActivityDate does not support date function WEEK_IN_YEAR'