Considerations – “Copy Data Element to New Location” Component

When using the Copy Data Element to New Location component, use the “Deep Copy” option if you mean to retain the original variable for comparison purposes and you intend to edit the values of the copied (new) variable.  See the demo for a better illustration, but here’s a scenario to hopefully help describe it:

Imagine I have a project in which I pull data from a SQL table and display it on a form.  The data is displayed in a ListSelect component, and the output variable is a complex data type called “SelectedItem”.

Now let’s say the following form allows the user to edit the record they selected on the previous form.  Let’s also say I want to audit and log the changes made to the values.  In order to do so, I’ll make a copy of the “SelectedItem” variable and copy it to a new variable called “CopiedItem”.  Let’s assume also that the Copy Data Element to New Location component does not have “Deep Copy” selected.

I then give the TextBox elements on the edit form the variable parts from the “CopiedItem” variable.  When a user edits these values and clicks “Save”, I want the workflow to then write to an audit table the original values in “SelectedItem” and the adjusted values in “CopiedItem” so that the exact changes can be referenced later.

The problem lies in the copy – again, check the demo project to see a better illustration.  If “Deep Copy” is not selected, for some reason, when the “CopiedItem” variable is edited, the original “SelectedItem” is changed along with it.

Hopefully this helps someone.  Personally, I once spent about 3 days trying to find a way around this problem before I accidentally stumbled into the “Deep Copy” fix, which doesn’t really seem very intuitive.

Featured Components

Copy Data Element to New Location



A demo project is available on the Demos page here.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s