You need to sign in to do that
Don't have an account?
citygirl403
Copy Activity History from one record to another
how to do you copy activity history from one record to another. I want activity history in both records. I thought this could be done by upsert using the data loader. When using data loader is moves the activity history to the new record.
Okay, if your user is unwilling to simply enter the Activities for the new Opportunity, then your only choice is to extract the Activity records using the Force.com Data Loader. Copy the Activity records that need to be cloned to the new Opportunity, and then re-parent them to the new Opportunity by inserting the new Opportunity Id into the WhatId field on the copied Activity records. Then using the Force.com DataLoader you can upload the copied Activity records and they will appear in the Activity History of the new Opportunity.
The error you got is because the Activity Id and the Activity Record Id are two separate animals.
As far as "Any solutions to make this easier..." my suggestion would be to tell your user to stop being a crybaby, suck it up, and just re-enter the Activities for the new Opportunity.
Lemme know if you need any help with this
All Answers
You would need to create duplicate Activity records and re-parent the duplicates to the new parent, then insert them using the Data Loader.
Activity is represented by Tasks in Salesforce Schema and Activity History is a separate object which houses the Closed Activity or Tasks. Salesforce schema is structured in a way that you that ideally you won't be allowed to copy the activity history in another object.
Can you please tell me your exact requirement why you want to copy the activity history into another task, may be I may be able to suggest a way out.
thank you for your suggestion. I am trying to copy the activity history in one Opportunity record to another Opportunity record. The opportunity owner insist the same activity history be in both records. I've tried the following and my data continues to be rejected.
1. created a report of activities with the activity ID
2. Click on Insert
3. Chose the Task Object
4. For the mapping, to map the field RecordTypeID, I dragged the field name to my file column header Activity ID.
When all is done, I have the errors, Task Record Type ID: id value not valid for the users profile: ACTIVITY RECORD ID.
Any solutions to make this easier are welcomed.
Thank you.
Okay, if your user is unwilling to simply enter the Activities for the new Opportunity, then your only choice is to extract the Activity records using the Force.com Data Loader. Copy the Activity records that need to be cloned to the new Opportunity, and then re-parent them to the new Opportunity by inserting the new Opportunity Id into the WhatId field on the copied Activity records. Then using the Force.com DataLoader you can upload the copied Activity records and they will appear in the Activity History of the new Opportunity.
The error you got is because the Activity Id and the Activity Record Id are two separate animals.
As far as "Any solutions to make this easier..." my suggestion would be to tell your user to stop being a crybaby, suck it up, and just re-enter the Activities for the new Opportunity.
Lemme know if you need any help with this
thank you for your reply. this has helped, specifically you stating the fields should be mapped.
Again, thank you.
Actually I was hoping you were gonna say that you told the user to "stop being a crybaby and suck it up".
//you can't create a new task record where the ownerid is inactive - grabbing a default user to set these to in this case
User default_user = [select id,name from user where name = 'Name of an active user here'];
Map<ID,User> inactive_user_map = new Map<ID,User> ([select id,name from user where isactive = false]);
//id of the record with activity history you want to copy
ID source_id = '00QV0000007xP5PMAU';
//id of the record you want to copy the activity history to
ID target_id = '00QV0000008O6wg';
List<Task> cloned_tasks = new List<Task>();
//you'll probably want to adjust the fields pulled in here to cover the custom fields and items you need in your instance
//whoid would cover a contact or a lead, if you're targeting something else, you'll want to use whatid
//ALL ROWS is necessary to get the closed tasks
List<Task> existing_tasks = [Select ActivityDate,CallDisposition,CallDurationInSeconds,CallObject,CallType,
CompletedDateTime,CreatedById,CreatedDate,Description,Id,IsArchived,IsClosed,IsDeleted,IsHighPriority,IsRecurrence,
IsReminderSet,LastModifiedById,LastModifiedDate,OwnerId,Priority,RecurrenceActivityId,RecurrenceDayOfMonth,
RecurrenceDayOfWeekMask,RecurrenceEndDateOnly,RecurrenceInstance,RecurrenceInterval,RecurrenceMonthOfYear,
RecurrenceRegeneratedType,RecurrenceStartDateOnly,RecurrenceTimeZoneSidKey,RecurrenceType,ReminderDateTime,
Status,Subject,SystemModstamp,TaskSubtype,Type,WhatId,WhoId
From Task t where whoid = :source_id ALL ROWS];
for(Task t : existing_tasks) {
//use the flags that make sense for what you want to accomplish here
task clone_task = t.clone(false,true,true,true);
//once again - use whatid depending on the scenario
clone_task.whoid = target_id;
if(inactive_user_map.get(t.ownerid)!=null) {
//Task has an inactive owner - switch to the default we decided on above
clone_task.ownerid = default_user.id;
}
cloned_tasks.add(clone_task);
}
System.debug('Coned Tasks : ' + cloned_tasks.size());
if(cloned_tasks.size()>0)
insert cloned_tasks;