Overview

Skill Level: Any Skill Level

The recipe focuses mainly on defining and use of the invariable constants within the solution created in IBM Business Process Management in the :
1)Process and Services
2)Coach views
3)Client Side Human Service(CSHS).

Ingredients

IBM BPM 8.5.7

Step-by-step

  1. 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.

     

    Javascript-Managed-file-1

    Fig 1 : Javascript Managed file

  2. Process and Services

    In the Process and the services, a variable can be assigned value directly as shown in Fig 2 in a script.

    2_Assigning-values-to-TWVariable-in-Process-and-services-1

    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)

     

    3_Conditional-statements-in-script-1

    Fig 3: Conditional statements in script

     

    4_Conditions-in-Gateway-1

    Fig 4: Conditions in Gateway

     

  3. 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).

     

    5_Coach-View-1

    Fig 5: Coach view

  4. 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).

     

    6_String-parameter-assigned-the-jsonString-1

    Fig 6: String parameter assigned the jsonString

     

    The parameter will hold value as :

    data-stored-in-Parameter-1

    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).

    7_CSHS-Server-script-1

    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).

     

    8_Conditional-statements-and-variable-assignment-in-CSHS-server-script-1

    Fig 8: Conditional statements and variable assignment in CSHS server script

     

    9_CSHS_Gateway-1

    Fig 9: CSHS Gateways

  5. Contribution

    Thanks to Shruti Pandey for contributing in the above solution.

5 comments on"Use Of Invariable Constants in IBM BPM"

  1. aks.bhargava January 13, 2019

    Very significant information which we normally miss or ignore during design. Appreciate your attention.

  2. sagar.samantaray January 13, 2019

    Very informative article

  3. Zafiris Keramidas January 16, 2019

    This is a nice idea. My contribution for improving this solution would be:

    – add a namespace to avoid conflicts between process apps
    – create a function for adding the constants so that the constant names and values are in one place

    For example:

    MYNS = { // e.g. same as the process app acronym
    CONST: {},
    CONSTJson: ‘{‘,
    addConstants: function (constants) {
    for (var i = 0; i 0 ? ‘,’ : ”);
    this.CONSTJson += ‘”‘ + c.name + ‘”:”‘ + c.value + ‘”‘;
    }
    this.CONSTJson += ‘}’;
    }
    }

    // Add the constants
    MYNS.addConstants([
    { name: ‘RETAIL_LOB’, value: ‘RTL’ },
    { name: ‘ACCOUNT_JOINT’, value: ‘JNT’ },
    { name: ‘ACCOUNT_ESCROW’, value: ‘ESC’ },
    { name: ‘RISK_LEVEL_LOW’, value: ‘1’ },
    { name: ‘RISK_LEVEL_HIGH’, value: ‘3’ },
    ]);

    • Zafiris Keramidas January 16, 2019

      it looks like the code snipped is not supported… some lines are formatting are lost.
      Trying again with commenting out the code:

      // MYNS = { // e.g. same as the process app acronym
      // CONST: {},
      // CONSTJson: ‘{‘,
      // addConstants: function (constants) {
      // for (var i = 0; i 0 ? ‘,’ : ”);
      // this.CONSTJson += ‘”‘ + c.name + ‘”:”‘ + c.value + ‘”‘;
      // }
      // this.CONSTJson += ‘}’;
      // }
      // }

      // // Add the constants
      // MYNS.addConstants([
      // { name: ‘RETAIL_LOB’, value: ‘RTL’ },
      // { name: ‘ACCOUNT_JOINT’, value: ‘JNT’ },
      // { name: ‘ACCOUNT_ESCROW’, value: ‘ESC’ },
      // { name: ‘RISK_LEVEL_LOW’, value: ‘1’ },
      // { name: ‘RISK_LEVEL_HIGH’, value: ‘3’ },
      // ]);

      • Zafiris Keramidas January 16, 2019

        Again a couple of lines are missing 🙁

        Inside the “for” loop it should have (without the quotes):

        “const c = constants[i];”
        “this.CONST[c.name] = c.value;”
        “this.CONSTJson += (i > 0 ? ‘,’ : ”);”
        “this.CONSTJson += ‘”‘ + c.name + ‘”:”‘ + c.value + ‘”‘;”

Join The Discussion