Create a Copy of a Business Object

One way of creating a new Business Object is to create a copy of an existing object.

The scriptUtil utility method, as shown below, is provided for doing this:
data.cust1 = factory.com_example_data.createCustomer();
data.cust2 = bpm.scriptUtil.copy(cust1);
data.cust3 = cust1;

The script in the example above, sets the cust2 process data field to refer to a copy of the Business Object that the cust1 process data field refers to, and cust3 to refer to the same Business Object that the cust1 process data field refers to.

The bpm.scriptUtil.copy() method performs a "deep" copy, which means that it copies all the objects contained by the Business Object being copied, as well as the Business Object itself. It is only for copying whole Business Objects, not for just copying BOM Primitive values.

To copy an array of business objects, use bpm.scriptUtil.copyAll(array)