Open topic with navigation

TIBCO Business Studio™ - BPM Edition 5.4.0

# Factories

For each package defined in the business object model in the project, or in any projects upon which the project depends, there is an instance of a factory available in the form script editors. These are accessed via the available factory variable in each script.

New instances of complex types are created via the use of these factories. Each factory has a set of superfluous methods that can be used to create instances of the classes defined within that package.

The factory for each package is referenced via an instance variable of the form: `factory.<business-object-model-name>`, where `<business-object-model-name>` is the fully qualified BOM package name, with "`.`" replaced by an underscore "`_`".

A `create` method for each class is provided with the signature:

    <class-name> create<class-name>([json | object])

For example, suppose the package `com.example.customer` contains classes for Customer and Address. We would create instances of each of these objects using the following:

    var address = factory.com_example_customer.createAddress();
    var customer = factory.com_example_customer.createCustomer();

A factory is only available for packages that directly contain class definitions. For example, there would not be a factory for the`com.example` package if there were no classes defined directly in that package.

The content assist in any script editor displays the available factories after typing `factory`. Only factories for packages in the current project or referenced projects are displayed.

Method | Return Value | Description
--- | --- | ---
    create<bom-class-name>([json | object])
| An instance of the given class | If no argument is provided to the method, a new object of the given type is returned. You can provide an optional argument that provides either a JSON string representation of an object of the given type, or a JavaScript object containing the same data. If you provide a wrong type of JSON or an array, the method throws a runtime exception.

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.