• Samina Diamond
  • 0 Points
  • Member since 2014

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 1
Hi ,
I am trying to change the contact owner of the contact on insert and I am directed to the page saying insufficient permission.
The profile has a limites access on contact that is only read edit and create. Change the Owner option is available in the UI but unable to control on the edit page
Here is the code
trigger UpdateCOwner on Contact (before insert, after insert)
//Query for the ARS Account Leader of the contact's Account 
//Set the contact ARS Owner value to Leader value obtained 
//Insert Record 
Contact c = new Contact();
Map<String, Contact> contactMap = new Map<String, Contact>();
for (Contact contact : System.Trigger.old) 

if (System.Trigger.isInsert)
string profileName = [select profile.name from user where id = :contact.OwnerId][0].profile.name;
if(profileName.indexOf('Call Center')>-1)
Account acnt = [select ARSaccountleader_lookup__c,ACWaccountleader_lookup__c from Account where Id=:contact.AccountId];
string acntLeader = [select ARSaccountleader_lookup__c from Account where Id=:contact.AccountId][0].ARSaccountleader_lookup__c;
//string acntLeader = [select ARSaccountleader_lookup__c from Account where Id=:contact.AccountId][0].ARSaccountleader_lookup__c;
//string test = acnt.ACWaccountleader_lookup__c;
contact.Created_by_Call_Center__c = true;
if(acnt.ARSaccountleader_lookup__c != null)
contact.OwnerId = acnt.ARSaccountleader_lookup__c;
else if (acnt.ACWaccountleader_lookup__c != null)
contact.OwnerId = acnt.ACWaccountleader_lookup__c;
//c = contact;

else contactMap.put(contact.Id,contact);

Can some one help with finding how this can be handled.A use with limited profile cannot create a contact with the differnt owner and this causing the problem.
Is there a way we can update the record after insert
Thanks in advance.
Thanks & Regards,

Message Edited by Suchitra on 03-07-2008 08:34 AM