Working with Single Instance Attributes of Business Objects

To add contact details to a Customer instance, you can write a script..

	if (data.cust != null)
	{
    		data.cust.phone      = phoneNumber;
    		data.cust.email      = emailAddress;
    		data.cust.address    = postalAddress;
	}

Ensure that no variables used to assign attributes are null. Otherwise, the script will cause a runtime exception that can cause the process to fail when the script is run.

If the address attribute of the Customer class is an attribute of an Address type rather than a Text type, the address attribute needs to be set to refer to an instance of the Address class before the attributes of the customer.address can be set. For example, the following can be done:

if (data.cust != null)
{
    data.cust.phone      = phoneNumber;
    data.cust.email      = emailAddress;
    if (data.cust.address == null)
    {
        data.cust.address = factory.com_example_data.createAddress();
     }
    data.cust.address.street   = streetAddress;
    data.cust.address.district = districtAddress;
    data.cust.address.city     = cityAddress;
    data.cust.address.country  = countryAddress;
    data.cust.address.postcode = postCode;
}