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
JoshVHJoshVH 

APEX Oddity

I have a very odd situation going on.  I have this query (
List<Task> TasksRemaining = [SELECT Id FROM Task WHERE Status != 'Completed' AND Status != 'Canceled' AND WhatId=:CustomObject[0].Id];)
in an apex script that is just trying to get the number of un-closed tasks related to an instance of a custom object.  The query works fine and correctly returns the number of un-closed tasks.  That is it works fine until I attach an email via the Outlook add-in to the instance of the custom object.  Once I do that this query always returns 0.  From the point of the call from the Outlook add-in forward this query always returns 0.  Even for different instances of the custom object that have un-closed tasks.  If I run the query from Eclipse it returns the id's of the un-closed task correctly.  Whenever the Apex runs though it returns 0 for the size.  The only way I can get it to return the correct number is to re-import the Apex code.  That process seems to reset whatever is causing this to return 0.  Any ideas why this is happening and why re-importing the Apex code into the org seems to fix it?  It makes no sense to me that the call from Outlook would actually make the code not function but I don't know what would result in this query returning 0 when there are un-closed task.  I ran this through the debug log and output the SOQL to the debug log and there is always a valid id in the whatid clause and if I copy the soql to eclipse and run it the correct number of tasks is returned.  Any help or insight would be appreciated.