Assigning a Business Object
Assigning a Business Object is by reference.
data.personDataField = data.car.owner; // Business Object assigned to data // field by reference data.personDataField.age = 25; // Also affects car.owner.age |
var tempPerson = data.personDataField; // Business Object assigned to // local variable by reference data.tempPerson.name = "Bob"; // Also affects personDataField.name |
var owner = factory.com_example_refval.createPerson(); data.car.owner = owner; data.owner.name = "Ludwig"; // Also affects car.owner.name; |
In the next example, although all assignments are by reference (there is only ever one Address), the final line of the script removes the Address from Customer, leaving Customer with no Address:
var address = factory.com_example_refval.createAddress(); data.customer.address = address; data.account.address = customer.address; // They both point to the same object |
If this script is modified to use scriptUtil.copy(…), account and customer end up with independent copies of the address:
Copyright © 2021. Cloud Software Group, Inc. All Rights Reserved.