Scripting
There are some changes to scripting in version 5.x, for example, process data fields are now wrapped in a
data object and factory methods have changed. Some differences are automatically fixed for you when you import your projects for the first time. Depending on the complexity and nature of your scripts, you might need to fix some scripts manually by addressing the problems markers raised on those scripts.
At run-time, instances of BOM classes are created to represent particular instances of the generic BOM class. These instances are referred to as Business Objects. You can retrieve and set business object attributes, using business data scripting. For example, in pre-version 5.x, you could have the following:
var custName = customerInstance.name;and you could set the value of the
Name business object property as follows:
customerInstance.name = "Clint Hill";In version 5.x, process relevant data are now wrapped in a
data object. To set the same value of the
Name process parameter or data field property, you must now do the following:
data.customerInstance.name = "Clint Hill";
createCustomer,
createOrder, and so on). For example, in pre-version 5.x, you could have the following:
com_example_ordermodel_Factory.createOrder()
In version 5.x all BOM factory methods are accessed via a single factory object. To use the same factory method in version 5.x, you must now do the following:
factory.com_example_ordermodel.createOrder()
Working with Enumerated Types (ENUM)
If you want to categorize objects as different types, instead of using a number or a free format string, you can use an Enumerated Type (ENUM). In pre-version 5.x, you could use unqualified names to define ENUMs in scripts. In version 5.x, this is no longer supported. You must use a fully qualified name (qualified by the package name) for the enumerations in the script. The qualified name of enumerations to be used in scripts is similar to the factory names, with the qualified name formatted to replace dot '.' by '_' an underscore character.
Secondly, the fully qualified name must now be wrapped in a
pkg object. For example:
com_example_shared_ColorEnum.REDbecomes
pkg.com_example_shared_ColorEnum.RED
Case Data Access Methods
Prior to ActiveMatrix BPM version 5.x, specific JavaScript classes were dynamically generated to handle specific BOM case classes. ActiveMatrix BPM version 5.x has been changed to provide a statically defined (that is, it is always there) JavaScript class that is used for all case classes, where the case class is identified in the method parameters using its fully qualified name (that is, "<bom_package_id>.<case_class_name>".
Upon migration from pre-version 5.0, scripts are automatically changed to use the equivalent new method, assuming there is an equivalent method, and that the referenced Business Data projects have been imported.
ScriptUtility
ScriptUtil provided methods to create various types of object, to modify
Duration objects, and to serialize business objects into or deserialize them from their XML representation in pre-version 5.x. These are no longer provided. ScriptUtility should now only be used for copying objects. See
ScriptUtil for more information.
Some Script Utilities No Longer Supported
The following script utilities are no longer supported:
DateTimeUtil. These methods were used to create date, time and date-time objects of the types used in pre-version 5.x.DataUtil.DataUtilprovided a single method that allowed you to create a List object for use in scripting in pre-version 5.x.
Regular Expression Patterns for Text Fields No Longer Supported
In pre-version 5.x, when defining a Primitive Type, text fields could be constrained to match certain patterns. Regular expression patterns are no longer supported.
List Objects No Longer Supported
In pre-version 5.x a process data field specified as an array could refer to multiple instances of a business object. Similarly, a BOM class attribute could refer to multiple instances of a business object. Multiple instances of business objects used to be handled using a
List object.
List objects are no longer supported. In version 5.x, you must use JavaScript
Arrays instead.
WorkManagerFactory and Process Classes
WorkManagerFactory and
Process classes have the following changes:
WorkManagerFactoryis renamed asworkManager.workManagerandprocessobjects are now wrapped in abpmobject.
Example 1
var theOfferSet = WorkManagerFactory.getWorkItem().getWorkItemOffers();becomes
var theOfferSet = bpm.workManager.getWorkItem().getWorkItemOffers();Example 2
var myActivityLoopIndex = Process.getActivityLoopIndex();becomes
var myActivityLoopIndex = bpm.process.getActivityLoopIndex();