-
Description
IBM Business Process Management(IBPM) doesn’t provide any specific pattern to maintain and use the invariable constants within the solution. During the development phase the constants are used to promote consistency, improve maintenance and reduce typographical errors. In the tool there are options like Exposed Process Value(EPV’s), Environment Variables and Resource Bundles , which are meant to store the business level constants. For an example : Gold rate or rate of interests can be used as EPV’s which can be changed as per the market values, URL’s as environment variables whose value depends on environment basis, and the UI labels can be stored as Resource Bundle.
The recipe focuses mainly on defining and use of the invariable constants within the solution created in IBPM in the :
1)Process and Services
2)Coach views
3)Client Side Human Service(CSHS).
The constants can be declared as javascript in managed file (server file). In the file, declare a variable (refer Fig 1, variable “jsonString”) which will be creating a json string for the constants and initialize the way shown in Fig 1.
Fig 1 : Javascript Managed file
-
Process and Services
In the Process and the services, a variable can be assigned value directly as shown in Fig 2 in a script.
Fig 2: Assigning value to a TWVariable in Process and services
This can also be used directly to check conditions in the script using conditional statements(refer Fig 3) as well as in the gateways(refer Fig 4)
Fig 3: Conditional statements in script
Fig 4: Conditions in Gateway
-
Coach views
In the coach view, the .js file can be uploaded in the “Included Scripts” section of the behavior which can be used in the event handlers as well as in the inline javascript section(refer Fig 5).
Fig 5: Coach view
-
Client Side Human Service(CSHS)
To access the constants in the Client Side Human Service(CSHS), execute the below line in the script of the process/service , and store it in a string type Parameter.(refer Fig 6).
Fig 6: String parameter assigned the jsonString
The parameter will hold value as :
Pass the string type Parameter as input to the CSHS. Declare an ANY type private variable in the CSHS and execute the below line in the server script of the CSHS(refer Fig 7).
Fig 7: CSHS Server script
The AnyObj can now be used in the server script in assigning values to the CSHS variables or for checking conditions(refer Fig 8). It can also be used in the gateways(refer Fig 9).
Fig 8: Conditional statements and variable assignment in CSHS server script
Fig 9: CSHS Gateways
-
Contributions
Thanks to Shruti Pandey for contributing in the above solution.