Dynamically Created Factory Methods
In addition, BPM scripting supports the use of dynamically created factory methods to create new Business Object Model objects.
This enables you to populate a data field with an instance of a Class defined in a Business Object Model that is referenced (directly or indirectly) from the business process. You can do this if the first use of that data field is in a Script task; it is not necessary if the field has already been initialized, for example in a form. You can call:
field=BOM_name_Factory.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),
- 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:
cust = com_myorg_customermodel_Factory.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 (cust == null)
{
cust = com_myorg_customermodel_Factory.createCustomer();
}
The Business Object Model object needs to have been created before any attributes defined in the Business Object Model can be assigned.
See the TIBCO Business Studio Concepts Guide and TIBCO Business Studio Modeling User’s Guide for more details on business object models.