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
Leah SchneiderLeah Schneider 

SOQL Query returns no results

I had a more complicated SOQL query that was only returning partial results.  I've since refined it looking to get to the bottom of the issue and I'm stuck in that I can't find a record that I know exists.

The SOQL Query: SELECT Id FROM Task WHERE Id = '00TU00000031qJT'
This query returns nothing.

The record page:
User-added image
A task with that Id definitely exists.
Best Answer chosen by Leah Schneider
Alain CabonAlain Cabon
Developer console > Anonymous console  ( CTRL + E )

Task myTask = [SELECT Id FROM Task WHERE Id = '00TU00000031qJT' ALL ROWS];
system.debug('task id ' + myTask.id);

Is your task archived (older than 365 days)?

Regards

All Answers

Alain CabonAlain Cabon
Developer console > Anonymous console  ( CTRL + E )

Task myTask = [SELECT Id FROM Task WHERE Id = '00TU00000031qJT' ALL ROWS];
system.debug('task id ' + myTask.id);

Is your task archived (older than 365 days)?

Regards
This was selected as the best answer
Leah SchneiderLeah Schneider

It's much older than 365 days.  It's from 2008.  Last updated in 2013.  However I have tasks from 2012 (last updated 2012) that I can see.  Is there a way to see if tasks are archived and work around this?

 

I'm trying to copy the "view all activities" functionality in Salesforce Classic in Lightning.

Leah SchneiderLeah Schneider
Wish I could delete my above response.  Thanks.  That worked.
Alain CabonAlain Cabon
365 days is the default limit but it can be increased (case).

How to increase your Archive Days limit
Change the Archive Days limit by creating a case with Salesforce Customer Support
https://help.salesforce.com/articleView?id=Increasing-Archive-Days-for-your-Organization&language=en_US&type=1

Regards.