0

What is the correct way to update a record based on the profile that created it?

For example if the user belongs to profile X then I want all Contacts they create to be assigned to Account Z. I want to accomplish this automatically and currently my thinking is a Process designed via the Process Builder. Is this correct or would a trigger or workflow be more suitable.

Note I have currently tried creating a Process as:

  • On Contact
  • If created by Profile with ID: XXX = True
  • Immediate Action to update Contact record (All) setting the field Account ID with type ID to the value of XXX (account record id)

I logged in via the user and this didn't work :(

  • Please make sure that you activate the process builder manually once created. – iamsfdc May 18 '16 at 10:58
  • yeah sorry I should have confirmed I did. – sfdc_beginner1 May 18 '16 at 11:02
1

We can automate this functionality using Process Builder however it doesn't work sometimes when record size is huge.

I would recommend you Process Builder only if you insert Contacts not very frequently and records are less at a time.

You can write trigger also for bulk records:-

trigger sample on Contact (Before Insert){

 for ( Contact c: trigger.new ){

   if ( UserInfo.getProfileId() == 'XYZ' )
   c.AccountId = 'Z';
}
}
  • So if we consider at most we would get maybe 50 contacts an hour from all of our staff. Would you say that's too many for the Process Builder? – sfdc_beginner1 May 18 '16 at 11:00
  • 1
    There is no issue with number of Contacts created at different time. Only issue might occur when 50 contacts are inserted at once like using DataLoader etc. – iamsfdc May 18 '16 at 11:13
  • Ah, apologies I understand now. Chances are the profile in question won't ever be doing that so I think we are safe. I appreciate it. You've answered my questions so I've marked it as answered. – sfdc_beginner1 May 18 '16 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.