change contact owner to match account - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Kathy FrantishKathy Frantish 

change contact owner to match account

I need to change all contact owners to match the account owner.  I have found a process that if the account owner changes, all contacts under that account are changed along with it...that seems to work fine.  BUT I also need to have a workflow rule for when a contact is added or edited that it also matches the account owner.  Can't see where I can change this Contact ownerID field to match the account ownerID.
Anyone have this workflow?
Thanks
Best Answer chosen by Kathy Frantish
Steve DoddSteve Dodd
They would just be additional (AND) conditions in your entry criteria:

User-added image

User-added image

User-added image

User-added image

 
* Use the actual Profile Name (I used "Marketing Profile" as an example)

Setup >> Administer >> Manage Users >> Profiles

 

All Answers

Steve DoddSteve Dodd
You can use Process Builder to assign the appropriate Owner (based on Account Owner) when a Contact is created or edited:

User-added image

Is your preference to do it with a workflow rule instead ?
Steve DoddSteve Dodd
A WFR will only allow you to set the new field value as a specific User...and not the Account Owner.

User-added image
 
Kathy FrantishKathy Frantish
I've not really used the process builder, but with what you gave me I'll give it a go.   I'll keep you posted.  THANKS
Kathy FrantishKathy Frantish
Steve
Setting thisup and I must select a Process starts when:  a record changes or it's invoked by another process.  Which one of these should I use for when it is created or edited.....
Steve DoddSteve Dodd
No worries...let me know if you have any questions.

You'll want to start the process using the Contact object (when a record is created or edited)...and your entry criteria would just be this:

Field Value = [Contact].AccountId 
Operator = Is null
Type = Boolean
Value = False

If you want to prevent Users from creating Contacts if they are not the assigned Account Owner, you can use a validation rule like this:
AND(
ISNEW(),
$User.Id <> Account.Owner.Id
)
Error Message: Only the Account Owner can create new Contacts for this Account

Otherwise, they can create the Contact (even if they are not the Account Owner), as long as they have access to do so...and then Process Builder will update the Owner field on the Contact to match the Account Owner.
 
Steve DoddSteve Dodd
RE: Setting this up and I must select a Process starts when

You can use this one...

User-added image

...and you'll want to start the process using the Contact object (when a record is created or edited)
Kathy FrantishKathy Frantish
In the Process Builder, creating a New Process, I have the Process Name Description and then the only dropdowns I have in the section:  The process starts when: A Record Changes  OR  It's involked by another process.  I don't see the option for when it is created or edited.  Will that come later?  Just checking as I go thru this as to what option I should take here.
Process builder
Steve DoddSteve Dodd
Here you go...this should help walk you through it...

Select A record changes where it says "The process starts when"

Click the blue Save button

Follow these screen-shots, saving you changes as you go



User-added image

User-added image

Click + Add Criteria to define the entry criteria (Use Contact > Account ID in the field picker, which will appear when you click into the Field section)

User-added image

Click + Add Action in the Immediate Action section to Select and Define Action

Choose Update Records as the Action Type

Give the Action a name

Click into the Record Type section to define the record you want to update

Click on the Select the Contact record that started your process radio button

Click the blue Choose button

Select Owner ID from the list of Contact fields

Set the Type to Reference

Click into the Value section to access the field picker

Select Contact > Account ID (not Contact Account ID > Account ID)

User-added image
Click the blue Activate button once you have finished building the process

Test

 
Kathy FrantishKathy Frantish
So, got thru that, and it works great when you add a new contact....BUT when I edit and existing contact it does not change the owner.  Any thoughts?
Steve DoddSteve Dodd
It's working in my Dev org when I test it by editing an existing Contact record owned by a User that doesn't match the Account Owner...OR by changing the Owner on the Account (Contact record automatically updates).

Mine also works when I create a new Contact record on an Account that is owned by a different User (Contact Owner updates upon Save).

How are you testing it ?

And did you specify to start the process when a record is created or edited ?

User-added image
 
Kathy FrantishKathy Frantish
Yes it is....
User-added image
Steve DoddSteve Dodd
Looks like you're starting out fine...do you want to post the other pieces of it ?

Also, you have the Recursion box checked to evaluate a record more than once...you don't need that to be checked
Kathy FrantishKathy Frantish
So I deactivated this....assuming you needed to do that to make a change, but when I open contact to uncheck the recursion it will not let me edit it.  Is there an edit button some place I don't see?
Steve DoddSteve Dodd
OK, so in order to modify an existing process (Active or Deactivated), you need to click the Clone button in the Process

User-added image


...then Save Clone as Version of current process

User-added image

Update the Description (optional)

...then click the blue Save button

You never really need to Deactivate a process unless you don't want it to run...but you can always Clone an Active process. The Active process will run until you Activate the newest version (or even an older version) of the Process.
Kathy FrantishKathy Frantish
I'll give that a shot after I get back from lunch & let you know.  appreciate your help!
Kathy FrantishKathy Frantish
Here are shots of my process (screen shots 2 & 3 are the update, but couldn't get it all on 1 page).  Still not updating a contact if I edit it.
User-added image
User-added image
User-added image
User-added image
 
Steve DoddSteve Dodd
You have the Advanced option selected in your entry criteria where it asks Do you want to execute the actions only when specified changes are made to the record?

By selecting this, the process will only run when the Account lookup field on the Contact record is changed from a NULL value to an Account ID, which only happens on Create...so it won't run upon Edit unless you un-check this box.

User-added image
Kathy FrantishKathy Frantish
SWEET!!!  That did it.  1 little checkbox, and......well now it works just fine & I'll put this into production.
I can't thank you enough for your help with this.
THANKS!!!!
Steve DoddSteve Dodd
You're welcome...please select a 'Best Answer' when you have a moment to mark the question solved and to close out the thread.

FYI - there are times when you will want to use that Advanced checkbox...

Example:
If you want to use Scheduled Actions (similar to time-dependent actions in workflow rules) for a process that starts when a record is created or edited...OR if you want to ensure the process ignores record changes that aren’t relevant to your defined criteria.

Trailhead has a great Process Builder tutorial and exercise if you want to take a look at it sometime to get more comfortable with using the tool:
https://trailhead.salesforce.com/en/modules/business_process_automation/units/process_builder


Feel free to reach out if you have any questions.


Thanks,
Steve D

 
Kathy FrantishKathy Frantish
Steve
Good morning.....I put this process into production late yesterday, and thought I had everything set correctly, as I went thru every step you gave me and had my process in the sandbox to compare to also.  Issue:
I started getting these emails within 5 minutes after I activated it.
Error element myRule_1_A1 (FlowRecordUpdate).
The flow tried to update these records: 0038000000Y93dDAAR. This error occurred: ALL_OR_NONE_OPERATION_ROLLED_BACK: Record rolled back because not all records were valid and the request was using AllOrNone header. For details, see API Exceptions.  All of the record numbers are different, so I must have messed something up.  I quickly deactivated this and figured I get back on this today.  Would you know of anything specific I should look for, or maybe I should just clone this and start going thru each step again.  What would you do?
THANKS & happy Friday
 
Kathy FrantishKathy Frantish
Steve
This is the info in the Record Update flow:
RECORD UPDATE: myRule_1_A1
Find all Contact records where:
Id Equals {!myVariable_current.Id} (003C000002AIbLgIAL)
Update the records’ field values.
OwnerId = {!myVariable_current.Account.OwnerId} (00580000001glwLAAQ)
Result
Failed to update records that meet the filter criteria.
 
Steve DoddSteve Dodd
Did the operation you performed when you received this error by any chance involve bulk records ? I only see one Id in the error message, but I wanted to ask since PB is not yet bulkified.

If not, does the individual record contain a null value in the Account(Id) lookup field ?

Last thing to check...do you have a Validation Rule, Trigger or Visual Workflow associated with the Contact object that may be interfering with it ?
Kathy FrantishKathy Frantish
So, here is what I believe the issue might be.  Our marketing team uses a product:  Discoverorg  for leads and they import the contacts and  accounts into SF.  This may be causing the bulk issue, I did not kick off any bulk updates, etc.  There are no validation rules, or trigger, etc. that would interfere with this.  Since they do this all the time, I don't even think this would work correctly if I only had this process kickoff when it was a new contact.  do you think this could be the issue?
Steve DoddSteve Dodd
Did the import contain more than 100 records ?
Kathy FrantishKathy Frantish
Most likely.  They sometimes do over 1,000
Steve DoddSteve Dodd
Process Builder cannot process more than 100 records at a time...we hadn't discussed mass importing of Contacts, otherwise I definitely would have mentioned that.

You can either modify your process to apply only to those Users in specific Profiles (not your Marketing folks that are doing the import) or sit with a Developer to create a trigger using bulkified code that can perform the functions.

If your Marketing Users are importing records using Data Loader, you can try changing the batch size in the Data Loader settings...the Default batch size is 200, which is of course too high for Process Builder.

Knowledge Article 230650 details the approach:

Data Loader inserts/upserts causing Process Builder errors​
https://help.salesforce.com/articleView?id=000230650&language=en_US&type=1
Kathy FrantishKathy Frantish
where would I modify the process to apply to everyone but the marketing team?
 
Steve DoddSteve Dodd
They would just be additional (AND) conditions in your entry criteria:

User-added image

User-added image

User-added image

User-added image

 
* Use the actual Profile Name (I used "Marketing Profile" as an example)

Setup >> Administer >> Manage Users >> Profiles

 
This was selected as the best answer
Kathy FrantishKathy Frantish
Thanks.  I'm going to talk with my manager about this, and see what he wants me to do.  I'll explain all of this to him, and let you know once again if I need some help.  Enjoy your day.
Steve DoddSteve Dodd
Thanks...and just so you have all of the information...this is another option:

You could always exclude Marketing from this initial process and then create a second criteria node (in the same process) that does apply to those records that were created or edited by the Marketing Users.

The update record action that needs to occur could be scheduled as a time lapse
Example:
0 HOURS after CreatedDate or 0 HOURS after LastModifiedDate

...or they could be scheduled for 1 HOUR after the point at which the action is queued

...but again, it's not going to handle more than 100 records, and you can't tell it to stop before it gets to number 101


User-added image
Brian OconnellBrian Oconnell
Contact owners are supposed to automatically change when an account owner changes, so why do we need the process builder?
Steve DoddSteve Dodd
That's partially true Brian...the cascade transfer of Contact ownership applies to any records that the prior Account owner also owned, but not those Contacts that are owned by someone other than the prior Account owner.

Example:
- Oscar owns the Account
- Juan owns the only Contact related to the Account
- The Account's ownership is transferred to Steve
- Juan remains the owner of the Contact record


Thanks
Samir MahtaniSamir Mahtani
Hey! Question on this! I followed the process and it worked. My only issue is that I will change the account owner and the contact owner wont update until I click into the contact and make a change to it. Is there a way to " refresh" all of the contacts so they reflect the new owners? 
Steve DoddSteve Dodd
Haven't experienced that issue Samir...if the process flow is setup correctly, the RecordTypeId field on Contact will update when your criteria on Account is met. 

Are you not seeing the refresh in the Owner column on the Account's related list (Contact), or do you have two separate records open and are not seeing one of them refresh ? Are you sure it's not an issue with the page being cached ?
Steve DoddSteve Dodd
Samir,

Are you able to post some screen-shots of how you're doing this in Process Builder ? That may help to determine why it's behaving differently than expected.


Thanks
Samir MahtaniSamir Mahtani
Hey Steve,

I apologize, my previous meggase came out weird and I realized after the fact. The process is working  very well now. Anytime I update an account owner, the contact owner will immediately update as well. I do have a question though. The process was created to have the contact owner reflect the new account owner, whenever I put an account in someones name. That is great for us going forward,however, I was wondering if there was a good way to update all of our current accounts so that the account owner matches the contact owner. Would I just use data loader for this? I will also post screen shots to show the process as well. 

Thanks,

Samir 
Steve DoddSteve Dodd
Yes, I would suggest Data Loader or another ETL tool (e.g. dataloader.io, XL Connector) to do that.
Samir MahtaniSamir Mahtani
Ok thank you very much! I will update this thread by tomorrow with screen shots so you and anyone down the line can see the steps I took. Thank you again, this was very helpful! 
Craig LaMorgeseCraig LaMorgese
Steve..thank you very much! I followed your process and  it worked .. !!
Steve DoddSteve Dodd
Nice work Craig !
某某 刘某某 刘
nice