Open topic with navigation

TIBCO Business Studio™ - BPM Edition 5.4.0

# 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;

Note: You can make a copy of the object first using the `scriptUtil.copy(…)` utility.

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:

    var address = factory.com_example_refval.createAddress();
    data.customer.address = address;
    data.account.address = bpm.scriptUtil.copy(customer.address);
    // Creates an independent Address

Did you find this helpful?

Yes No
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO Business Studio™ - BPM Edition

Copyright © 2015-2023. Cloud Software Group, Inc. All Rights Reserved.