2

I am trying to create a process builder that fires as follows: Account owner is changed (standard functionality then changes the opportunity owner to = the account owner). When the resulting opportunity owner changes I want to create a record for object C. I currently have a process builder that fires correctly (creates record for Object c) when directly changing the opportunity owner.

4
  • Does the account has many opportunities under it? If so how are you changing the owner of a Particular Opportunity?
    – Goki
    Aug 27 '15 at 1:01
  • Does your account owner change happen directly on one account or through the mass transfer wizard?
    – Mark Pond
    Aug 27 '15 at 1:24
  • 1
    It won't work because that black magic SF does on those opportunity owner changes don't fire workflows (or processes). You can, however, use a headless flow to do what you want that can trigger off the account owner change. I don't know what you're doing with the opportunities and object c but if you shed some light on that I could probably whip up a flow that will do what you want. Aug 27 '15 at 1:42
  • @cricketlang Object C record has a lookup relationship with the Opportunity record and the owner of Object C record is set to the opportunity owner when Object C record is created. (Hence multiple Object C records since opportunity owners can be changed!) Aug 27 '15 at 12:00
1

So to fix this on owner changes that come from the Account level, since workflows and processes won't fire off this owner change, we can make a headless flow that we can then execute as the action when Account owner changes.

Lets start by creating the flow. When you create it, be sure to select it as an Autolaunched Flow, which means it requires no user interaction and can be called from a Process.

enter image description here

Next, we will need to setup a few input variables that will be used to both locate opportunities linked to the account, as well as the new Account Owner ID that we wish to assign to the newly created Object C.

enter image description here

enter image description here

Our first step (and start step) in the flow will be to lookup Opportunities that are linked to the Account ID. Assign the return value to a new Sobject Collection Variable.

enter image description here

After we have the Opportunities, we will loop through them with a new Loop step. We will loop through the LinkedOpportunities and assign a new Loop Sobject Variable. You only need the Id field to be returned.

enter image description here

For every "opp" in the collection, we want to create a new record. Here is where we will define anything that we want to set on our Object C record we are creating. Here is where we will set the OwnerId of the new Object C to the accountownerid and set the opportunity to be the current opp.id we are at in the loop. This creates your object C for every opportunity linked to the source account and sets the ownerid to the account ownerid. Save and activate the flow.

enter image description here

Now we just need to create a Process on Account that will fire this flow. Use the same logic you are using on your opportunity process to fire off on account owner change, only instead of trying to create an object c record, select Flow as your action and then select the Flow you just created.

enter image description here

After all this, you should be good to go. This will fire off anytime the account owner changes, and will create object C's for every opportunity linked to that account, link it to the opportunity, and set the owner as the new account owner. Let me know if this doesn't work for you.

enter image description here

3
  • Great news! Glad you got it worked out! Aug 31 '15 at 18:52
  • @cricketlangI have been doing some additional testing and if there are two or more opportunities it is only creating a record on one opportunity and not the other one Sep 2 '15 at 18:22
  • How do you have your loop step setup? It should be advancing to the record create step for every element in the LinkedOpportunities collection. Sep 2 '15 at 18:44

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.