Working with Single Instance Attributes of Business Objects

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

	if (null != cust)
	{
    		cust.phone      = phoneNumber;
    		cust.email      = emailAddress;
    		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 (null != cust)
{
    cust.phone      = phoneNumber;
    cust.email      = emailAddress;
    if (null == cust.address)
    {
        cust.address = com_example_scriptingguide_Factory.createAddress();
     }
    cust.address.street   = streetAddress;
    cust.address.district = districtAddress;
    cust.address.city     = cityAddress;
    cust.address.country  = countryAddress;
    cust.address.postcode = postCode;
}