cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jimmytheduck
Regular Visitor

Cloning a record using Command Bar Editor

Hi,

I have a requirement to copy selected columns on a Dataverse record (custom table) into a new record. There are a series of child records which should also be copied across and associated to the record. I'd like to approach this by creating a 'Clone' button using the new command bar editor to avoid installing a smart button solution, however I'm encountering some difficulties passing the 'Parent' cloned record to the Child Records.

 

I found this blog which offers helpful advice on doing exactly this requirement: Clone records with Power Fx & custom command bar button - Jukka Niiranen, and provides the following code:


Set(ClonedProduct, Patch(Products, Defaults(Products),{Name: "Copy of " & Self.Selected.Item.Name, 'Product Category': Self.Selected.Item.'Product Category', Vendor: Self.Selected.Item.Vendor, Description: Self.Selected.Item.Description})); ForAll(Self.Selected.Item.Assets, Patch(Assets, Defaults(Assets),{Name: "Copy of " & Name, Vendor:ClonedProduct.Vendor, Product:ClonedProduct, 'Purchase Date':Today(), 'Purchased From':'Purchased From', 'Purchase Cost':'Purchase Cost', 'Warranty End Date':'Warranty End Date', Description:Description})); Notify("Product " & Self.Selected.Item.Name & " and its assets have been cloned. Please open the records and update the necessary fields.")

 

However, the Set() element no longer appears to be supported, and neither is UpdateContext, or Collect or Clear Collect, any ideas on how I could get this to work?


1 ACCEPTED SOLUTION

Accepted Solutions
jimmytheduck
Regular Visitor

If anyone stumbles across this in the future, I managed to resolve the above issue by using the With() function

View solution in original post

1 REPLY 1
jimmytheduck
Regular Visitor

If anyone stumbles across this in the future, I managed to resolve the above issue by using the With() function

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,122)