You need to sign in to do that
Don't have an account?
Bharti Harimohan
I am getting 'Insufficient Privileges' error while changing Campaign owner in apex trigger :
if(trigger.isbefore)
{
if(trigger.isInsert)
{
if(!CRMTrainingSetting.IsTrainingEnv__c){
//Preparing a set of distinct Users
Set<Id> ownerIds = new Set<Id>();
for(Campaign c : trigger.new)
{
ownerIds.add(c.OwnerId);
}
Map<Id, CRM_Assistant__c> assistantMap = campaignTriggerHandler.getcrmAssignment(ownerIds);
Map<Id, User> userMap = campaignTriggerHandler.getusers(ownerIds);
Map<Id, User> parentuserMap = campaignTriggerHandler.getParentUsers(ownerIds);
for(Campaign camp : trigger.new)
{
if(camp.Ownership_Assignment__c != null)
{
//both lines not working
camp.OwnerId = assistantMap.get(camp.Ownership_Assignment__c).Parent_User__c;
camp.OwnerId = '005J0000002Fquj';
}
}
}
}
}
Please advise if can change the campaign owner through APEX or not?
Thanks!!
Bharti
{
if(trigger.isInsert)
{
if(!CRMTrainingSetting.IsTrainingEnv__c){
//Preparing a set of distinct Users
Set<Id> ownerIds = new Set<Id>();
for(Campaign c : trigger.new)
{
ownerIds.add(c.OwnerId);
}
Map<Id, CRM_Assistant__c> assistantMap = campaignTriggerHandler.getcrmAssignment(ownerIds);
Map<Id, User> userMap = campaignTriggerHandler.getusers(ownerIds);
Map<Id, User> parentuserMap = campaignTriggerHandler.getParentUsers(ownerIds);
for(Campaign camp : trigger.new)
{
if(camp.Ownership_Assignment__c != null)
{
//both lines not working
camp.OwnerId = assistantMap.get(camp.Ownership_Assignment__c).Parent_User__c;
camp.OwnerId = '005J0000002Fquj';
}
}
}
}
}
Please advise if can change the campaign owner through APEX or not?
Thanks!!
Bharti
Shashank (Salesforce Developers)
It is possible to change campaign owner using Apex. Please check if you have "Transfer Record" permission on your profile and "Marketing User" checkbox enabled on your user detail page.
Roman Riabenskyi
Shashank thank you so much for your answer! I didn't even notice there is a permission for transfering records, so when I checked "Transfer Record" permission it worked! Thank you!