The use case is familiar to any seasoned Salesforce consultant: your client needs their records to match their business workflow, say, by transforming closed Opportunities with Products into Orders with Products. Or, perhaps you’ve built a custom “Project” module for a client who sells professional services and needs to track their delivery milestones after launch.
Conventional Salesforce wisdom (and repeated scouring of the Success Forums) would lead you to believe that generating parent and child object records at the same time is best handled with APEX Triggers or Flows — and though that is technically true — the advantages of configuration with Process Builder are well known, especially for clients without much budget for custom development. Here’s how it’s done:
1. Opportunity Object
2. Order Object
3. Opportunity Product Object
Starting Object: Opportunity (when a record is created or edited)
Condition: This is up to your discretion. Some folks may want to simply generate orders when an Opportunity is set to a “Closed Won” stage; other clients may require some post-sale actions prior to producing orders for fulfillment or synchronization to finance systems. My preferred solution is to create a checkbox field on the Opportunity called “Generate Order” so that we can create a simple Update Record Lightning action on the page layout to launch this process. Regardless of your condition, make sure to check the setting to “execute the actions only when specified changes are made” — otherwise you’ll end up generating new orders every time you edit the Opportunity!**
**Admins want to know – why oh why isn’t this “advanced” setting defaulted to true? 🤦
Starting Object: Order (when a record is created or edited)
Condition: Source Opportunity field is not blank (Does not equal / Global Constant / $GlobalConstant.Null). This ensures that any Orders created without a pre-existing Opportunity do not accidentally trigger this process and cause it to fail.
Action: Pass Order ID to Opportunity Products – this ensures that your Opportunity Products have a direct relationship to the Order for which they will pass along their data as new Order Product records.
Starting Object: Opportunity Product (when a record is created or edited; also set the Recursion Flag to true!)
Condition: Generated Order field is not blank (Does not equal / Global Constant / $GlobalConstant.Null). This is the field that should have been populated by the action of Process #2.
Action: Create Order Products: make sure to include all required fields in your mapping. Here’s a sample of a basic mapping of the fields.
That’s it. You’re done! Take a look at the video below (in fullscreen for legibility) to see how this works!