@WarrenBelzI would use a similar approach. However, I think that @boedern is looking to also increment an ID field to not create an exact duplicate of the record, but instead clone the record as a new unique record.
This requires a relatively basic UpdateIf pattern to what you suggested.
For my example, I'll build a collection
ClearCollect(
colMain,
{
mainID: 1,
mainName: "Record 1",
mainDate: Today()
},
{
mainID: 2,
mainName: "Record 2",
mainDate: Today()
}
)
Then I'll add a Gallery and use colMain as the Items property. I mapped the fields, then added another control to trigger the clone. For the OnSelect of that control, I added the following function.
Select(Parent);
// Collect the Item into a temporary collection
ClearCollect(
colClone,
ThisItem
);
// Update the necesssary properties of the Clone
UpdateIf(
colClone,
mainID = mainID,// Identifer column, but any column will work
{
mainName: Concatenate(
mainName,
" (Clone)"// Appends the (Clone) text for easy identification
),
mainID: Max(
colMain,
mainID
) + 1// Increments the Max ID from colMain by 1
}
);
// Collect the Cloned item into Main
Collect(colMain,colClone);
// Cleanup isn't necessary, since we begin with a ClearCollect
Since my colMain's ID column is a number, I can simply increment it by 1 to get a new incremental number. This is why I was asking initially about your ID column, to understand how we could make/generate a unique ID. If it's not a number, we may need to change that part of the function, but the rest of the cloning operation will work.