Factory Methods

In addition, TIBCO BPM Enterprise scripting supports the use of factory methods to create new Business Object Model objects.

You can call:

field=factory.BOM_name.createClass();

where:

  • field is the name of the data field to be populated, and must correspond to a process field defined as an External Reference to class in the Business Object Model,
  • BOM_name is the Business Object Model name, with any dots replaced by underscores (so com.example.BOM would become com_example_BOM),
    Note: Note that this is the Name of the model, not the Label.
  • Class is the name of the Business Object Model Class object,

For example, assume that there is a Business Object Model called com.myorg.customermodel, and that it contains a Class called Customer. To use a script to create an instance of this Class in the field cust, you would call the corresponding factory method as follows:

data.customer = factory.com_myorg_customermodel.createCustomer();

As noted above this only needs to be done if the cust field has not already been initialized. You could check to see whether it has been created before invoking this line of the script, for example:

if (data.customer == null)
{
data.customer = factory.com_myorg_customermodel.createCustomer();
} 
	 

The Business Object Model object needs to have been created before any attributes defined in the Business Object Model can be assigned.