Copying a record in wf

Hi!

How can I copy a record in a workflow without modifying the original one?

currently: Triggering (recordA) → copy the recordA into a new one (compose record maker) recordB → modify a value on recordB → recordA gets modified along with recordB.

I don’t want recordA to be modified. I tried to use the composedRecordValue type, but it didn’t help. For it seems that it does not matter how I try to copy the values; in the background, it is always a reference instead of a copy, that’s why the original value is modified also.

image

In my opinion, the copy.field = “modified” expression should not reflect back onto recordA.values.field’s value.

Instead of copying the complete record, with recordID and other system values, maybe it’s better to just copy record.values? So, recordB.values = recordA.values. Did you try that?

I have tried it; however, it seems even if I do this way, recordA’s values get modified, which is not the intended way. If I understand correctly, this ComposeRecordValue type should be a copy, not a ref, right?

Currently, I solve this by copying the values one by one. My problem with this is that I have almost 20 fields in my module, and It is not convenient to copy this way. Also, if a new field gets introduced, I have to modify my workflow manually.

Oo, indeed, it fails. I have been saving the record before also, but it still modifies recordA’s values. I’ve made a bug report. When I copy record values in a workflow to a new record, I cannot update the values without it updating the value in both records. · Issue #1778 · cortezaproject/corteza · GitHub

1 Like