Overview
A regular requirement we come across is where a record needs to be cloned (copied) as well as its child and grandchild records. In this article we show how to add a button to the Account form that will:
- Clone the Account
- Clone all Opportunities related to that Account
- Clone all Product Line items related to any of those Opportunities
North52 Decision Suite
The North52 Decision Suite solution works like this:
- A Formula is set up on the Account which clones the Account, its Opportunities and their Product Line items
- A Quick button is created that calls this Formula
Set up Formula and Quick Button
Formula
- Create a new Formula, setting the following values in the Formula Guide:
- Source Entity set to Account
- Set Formula Type to Clientside - Calculation
- Select the Classic editor
- Select Create
- Change the Name of the formula to Multi-Level Cloning
- Click Create
- Copy and paste the following Formula:
Smartflow( SetVar('ClonedAccount',Clone('account',[account.accountid],'true') ), ForEachRecord( FindRecords('opportunity','parentaccountid',[account.accountid],SetFindSelect('opportunityid'),'50','true'), SetVar('CurrentClonedOpp', Clone('opportunity',currentrecord('opportunityid'),'product_opportunities','true')), UpdateRecord('opportunity', GetVar('CurrentClonedOpp'), SetAttributelookup('parentaccountid','account', GetVar('ClonedAccount')) ) ) )
- Click Save
Quick Button
Please see the article here for instructions on how to add a Quick Button to a form.
Testing
To test this Formula, open an Account and click the button.