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
randombardrandombard 

Reparent activity more then 365 days old

Hi All,

 

I have the following that works perfectly however I have noticed that anything more then 365 das old doesnt get re-arented.

 

I assume this is due to it being archived in some way?

 

I can re-parent manualy so they dont become read only, is it just that they cant be re-parrented programaticly when they are that old?

 

Code:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
trigger MigrateRelatedOb on lead (After insert, After update) 
{
for(lead L: trigger.new)
if((L.Old_Contact_ID__c<>''))
{
//move tasks
For(Contact C:[select id from Contact where Contact.ID = :L.Old_Contact_ID__c])
    {
    List<Task> TaskToMove = new List<Task>();
    {For(Task T:[select id, WhoID, WhatID from Task where WhoID = :C.Id])
    {
    T.WhoID = L.Id;
    T.WhatID=null;
    TaskToMove.add(T);
    }
Update TaskToMove;
     System.debug('Success');
}
{
//move events
List<Event> EventToMove = new List <Event>();
{For(Event E:[select id, WhoID, WhatID from Event where WhoID = :C.Id])
    {
    E.WhoID = L.Id;
    E.whatID=null;
    EventToMove.add(E);
    }
Update EventToMove;
     System.debug('Success');
}
}
//delete The contact
delete C;
}
}
else
{
System.debug('No Lead Found');
}
}