+ Start a Discussion
GauravKumarGauravKumar 

Task Record does not showing All Task List through SOQL

Hi All,

 

I Have fetech Opportunity Record with Task in Sub query. My Query is Like This 

 

Select Id, Name,

(Select Id, ActivityDate From Tasks)

From Opportunity Where IsClosed=False And BCD_Firm__c = true  And Regional_Manager__c = 'XYZ' Order By Regional_Manager__c 


This Query is Returning Opportunity List and it is showing only only Last 1 -2 Years Task not all Task List.

 

I have also fetched Separately Task by Using this Query but this This returns No Tasks for the Selected Opportunity

Select Id, ActivityDate From Task Where WhatId = 'ABC'

 

Here 'ABC' is Opportunity ID

 

 

Even Though Tasks Related List in organization show activities. I could not find proper explanation for this behaviour but i think SOQL query is auto filtering activities which are very old like tasks which are 4-5 years old. 

 

Can anybody Help me to figure out This Problem ? 

 

Best Answer chosen by Admin (Salesforce Developers) 
GauravKumarGauravKumar

Thanks Jim Rae For Help

Yes you are right When i fetched Task then it is showing according to your describe condition.

Thanks All For Help

 

All Answers

JimRaeJimRae

According to the help:

 

Salesforce.com archives older activities according to the conditions below:

  • Events with a due date greater than 365 days old
  • Closed tasks with a due date greater than 365 days old
  • Closed tasks without a due date that were created more than 365 days ago

Archived activities can be viewed only in export files, printable view, or by clicking View All on the Activity History related list.

Administrators can delete archived activities using Mass Delete.

Archived tasks are not included in reports. However, you can report on open or completed tasks.

 

This is probably what is causing your issue.

 

bob17bob17

To get the archived Tasks you need to include "ALL ROWS" in your query.  When you do this you need to be sure to also explicity exclude the deleted records (IsDeleted = false).

 

for example:

 

SELECT Id, ActivityDate FROM Task WHERE IsDeleted = false LIMIT 1000 ALL ROWS 

GauravKumarGauravKumar

Thanks Jim Rae For Help

Yes you are right When i fetched Task then it is showing according to your describe condition.

Thanks All For Help

 

This was selected as the best answer
CloudyCloudy

Hi,

 

I tried this query in Dataloader to export all tasks that I have imported for an update

Select Id, ActivityDate FROM Task WHERE CreatedById = 'IDIDIDID' AND LastModifiedById = 'IDIDIDID' AND IsDeleted = false ALL ROWS 

and I get the following message:

All ROws not allowed in this context.

 

What could I do to get an export of all my tasks?

GauravKumarGauravKumar

"All ROWS" functionality is added after spring release."ALL ROWS" works with API Version 18.0 and in eclipse it will not run due

use like this in apex class it will work

 

Task[] tasklist = [Select Id, ActivityDate FROM Task WHERE CreatedById = 'IDIDIDID' AND LastModifiedById = 'IDIDIDID' AND IsDeleted = false ALL ROWS ];

 

this will return task list and export this task list

 

CloudyCloudy

Thank you for your answer, but I'm a begginer, I don't know apex and how to use them.

 

Is there a simple way to export or delete all my activities to made a mass update or a mass insert with the corrections?

 

Thanks,

 

GauravKumarGauravKumar

Yes There is a simple way to export you Activities

1. There is no Tab Related to Activities is Present in Salesforce.

First Create Custom Visualforce Page Tab for Activities

 

Then Paste this in Visualforce Page which you created for Activities Tab

 

<apex:page standardController="Event" tabStyle="Activities__tab" sidebar="true" showHeader="true" name="Activities" label="Activities">
    <apex:enhancedList type="Activity" height="750" rowsPerPage="25" id="ActivitiesList"></apex:enhancedList>
</apex:page>

 

 

This Page will show all Activiies .

 

2. Create StandardSetController Cladss and vf page here you can put your code for export data and also for mass update

 

<apex:page cache="true" standardController="Task" tabStyle="Activities_VF_tab" recordSetVar="activities" extensions="extActivitiesExport"
            contenttype="application/vnd.ms-excel#billings.xls" action="{!export}">
    <apex:form id="theForm">       
        <apex:pageBlock title="">
            <apex:pageBlockTable value="{!selected}" var="a">
               <apex:column value="{!a.ID}"/>
               <apex:column value="{!a.ActivityDate}"/>
               <apex:column value="{!bill.Description__c}"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>    
</apex:page>

 

put this code in extActivitiesExport Class

 

public with sharing class extActivitiesExport  {

    ApexPages.StandardSetController con;
    public extActivitiesExport (ApexPages.StandardSetController controller) {
        con = controller;
    }
    public Boolean generateTestException { get;set; }
    public PageReference export() {
        List<Task> seletedBillings = (List<Task>) con.getSelected();
        return null;
    }
}

 

if tyou want to do sonthing with export like update anyu field calue etc then put your code in export()

 

This will export selcted Activities(Task) data in excel

 

Yasin Pardhan 1Yasin Pardhan 1
According to this link you can have Salesforce extend the archive dates up to 2555 days from the current 365 days: https://help.salesforce.com/apex/HTViewSolution?urlname=Increasing-Archive-Days-for-your-Organization&language=en_US