2

I have a custom object with a lot of variables and I need an exact copy of it without having to define all the fields derived from the Get Records element.

Is there a way to clone a record in a flow instead of defining all the fields in a new variable?

3 Answers 3

3

I don't think there is native clone functionality, An object can have up to 800 fields, cloning them by adding each variable might not be maintainable.

If you can use Apex, you can pass a variable from Flow to Apex Invocable. The apex will clone the record(Omit audit fields like CreatedDate, LastModifedBy, etc) and return sobject back to you so you can insert.

0

Apparently, the solution is to call a subflow to clone a record, by passing the record to be cloned.

https://www.linkedin.com/pulse/clone-records-easily-spring-20-lightning-flow-adam-white/?trackingId=6w5pMUAsSPi7q5dXRpGmYg%3D%3D

0

Just assign the source record to the target record. Use the standard assignment element, with a variable of type record for the object. Eg sourceRecord (var type record, using CustomObject(your name) and targetRecord with same var type/object.

Left hand side of assignment has the targetRecord, assignment operation is "equals", right hand side is source record.

Tip1: when enter variable names, remove the period at end of the autofill as do not need the fields, just the whole object.

Tip2: everything is copied/cloned as is (a complete replica for all fields including lookups), including standard fields created date, created by, last modified date, last modified by fields from the source record. You will need to update these field values in a following assignment, eg set created date and last modified date to $Flow.CurrentDate.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .