Cloning existing records is a common requirement in the Dynamics world, across any module. It is especially useful for sales professionals who frequently clone quotes and opportunities, saving them a significant amount of time. In this guide, I will explain how to clone an existing record exactly as it is, or how to select the new customer and contact details and clone it with the new information.
We will achieve this through the small custom page and power automate flow. We will initiate the clone from the custom page which triggers the flow and creates the new record.
Custom page screen which opens as a popup to select the customer and contact once you select we will show some waiting screen to the user while the new record is getting created.
create a new button by using ribbon workbench to create a new button and open the custom page.
Custom page design:
Waiting screen for the user to wait while the record is getting created

Note: Please add this custom page to Modern driven app you want to use.
On the custom page clone button on select property use the below code to trigger the flow to create the new record.
// Trigger Flow to create Quote & Opportunity
If(
!IsBlank(txOriginalQuoteId),
Navigate('Grey screen');
Set(VarQuote,CloneQuoteandOpportunity.Run(glAccountSearch.Selected.Account,
glContactSearch.Selected.'Contact (contactid)',
txtQuoteandOpportunityName.Value,
tglRecalculatePriceYesOrNo.Checked,
txOriginalQuoteId.Value,User().Email));
Launch(VarQuote.newquotelink,{},LaunchTarget.Replace);
);
Please put the below on app on start properties
Set(varRecordQuoteId, If(
IsBlank(Param("recordId")),
GUID("ec337351-5510-eb11-a813-00224806a2ff"),
GUID(Param("recordId"))
));
Set(varSelectedQuoteRecord,
LookUp(Quotes , Quote = varRecordQuoteId)
);
Text input of Quote and opportunity name in value properties
LookUp(Quotes, Quote = varSelectedQuoteRecord.Quote, Name)
To filter the accounts , Put the below code on Items property of the accounts gallery.
If(
IsBlank(txtbAccountSearch.Value),
Filter(Accounts,'Account GUID' = varSelectedQuoteRecord.Account.'Account GUID'),
Search(
Accounts,txtbAccountSearch.Value,name))
To filter the contacts , Put the below code on Items property of the contacts gallery.
If(IsBlank(txtbContactSearch.Value),
Filter(Contacts,'Company Name' = glAccountSearch.Selected, Status = 0),
Search(Filter(Contacts,'Company Name' = glAccountSearch.Selected,
Status = 0), txtbContactSearch.Value,'Full Name')
)
To select the default contact of varSelectedQuoteRecord, put the below code on default property of the contact gallery.
LookUp(Contacts, 'Contact GUID'= varSelectedQuoteRecord.Contact.'Contact GUID')
Now lets start build the flow to create a new record.
Create a manually trigged flow
Get all the record details
Get the current user details
Create new opportunity
Create a new quote , You have for each loop here because I am setting the current user details form the list of users from above.
List down the quote lines
Check if the price to be recalculated?
If price is to be recalculated to no, create quote lines exactly same
If price is to be recalculated to yes
Create environment variables
Environment URL
App ID
Now finally send the response to power apps, which will redirect to the newly created cloned quote record.
Thank you for visiting the blog. 🙏
Comments
Post a Comment