LSPS documentation logo
LSPS Documentation
Editable Decision Table

Required result: Decision table for resolution of employee position level based on their years of experience that is persisted and can be edited from the Process Application.

You can download an example implementation here. To import it to your workspace, create a GO-BPMN project; right-click the project and go to Import > Archive file; select only the positionLevelResolver directory, which is a module, and click Finish.

  1. Import the dmn module into your module: In the GO-BPMN Explorer, right-click your module, click Module Imports, click Add and double-click dmn.
  2. Design the decision table:
    1. Create the decision table definition: right-click the module, go to New -> Decision Table Definition, enter the file name and click Finish.
    2. Keep the default FIRST hit policy and LSPS as the expression language for the business rules.

      Note: While you can use SFEEL as the expression language for the business rules, it restricts the options, such as, using the resources of the Standard Library and accessing the contexts.

    3. Define the input parameter with the number of years of experience:
      1. Rename the default input parameter to yearsOfExperience.
      2. Set its data type to Integer.
    4. Define the output with position level:
      1. Rename the default output parameter to level.
      2. Set its data type to String.
      3. Define its options as Strings of the possible level, such as, "Associate Engineer", "Engineer", "Senior Engineer", "Principal Engineer".
      4. Add rules for different yearsOfExperience input: click + below the table and define the age ranges as expressions.

Now you need to create a form, and a document with the form so you can access it from the Process Application:

  1. Create a Form with the Decision Table component:
    1. Create a form definition: right-click the module, go to New -> Form Definition, enter the name PositionDecisionTableForm and click Finish.
    2. Create local variable positionLevelDecisionTableVar of the type of your decision table: it will hold the decision table and initialize it to the stored decision table if such a table exists.
    3. Initialize the positionLevelDecisionTableVar, for example, in the form constructor:
      public PositionDecisionTableForm(){
      positionLevelDecisionTableVar := new positionLevelResolver(false);
      //if cannot load the decision table, create a new one and persist it:
      if positionLevelDecisionTableVar.load("storedPositionTable") == false then
      positionLevelDecisionTableVar := new positionLevelResolver(true);
      positionLevelDecisionTableVar.save("storedPositionTable")
      end
      }
    4. Design the form:
      1. Insert a Vertical Layout component.
      2. Insert a Decision Table Editor component into the layout and set its properties as follows:
        • Decision table: positionLevelDecisionTableVar
        • Rights: [DecisionTableRights.CAN_EVERYTHING]
      3. Insert a Button that will persist the changes on the decision table: this is performed by calling the save(<ID>) method on the table. The click listener closure could be set to something like { e -> positionLevelDecisionTableVar.save("storedPositionTable") } Make sure you are saving the table under the same String ID as you are using when loading it in the form constructor.
    5. Create a document with the form as its UI definition.
  2. Create the PositionEvaluator form definition for the years-of-experience input and evaluation with the following:
    • Local variable positionLevelDecisionTable of the type of your decision table.

      Initialize the variable from the constructor of the form to the persisted decision table, for example:

      public PositionEvaluator(){
      positionLevelDecisionTable := new positionLevelResolver(false);
      if (positionLevelDecisionTable.load("storedPositionTable") == false) then
      positionLevelDecisionTable := new positionLevelResolver(true);
      end;
      }
    • A Decimal Field component for input of years of experience with the ID yoe and the binding set to a valid value
    • A Label component with the ID result that will display the position level
    • Button to request the level evaluation on click and set it as the value of the result field
      //example click listener that returns the decision,
      //writes it to the result field:
      { e ->
      if (yoe.getValue()== null) then
      result.setValue("Enter an integer.")
      else
      result.setValue(positionLevelDecisionTable.evaluate(yoe.getValue() as Integer))
      end
      }
    1. Create a document with the UI definition set to new PositionEvaluator()
  3. Run a LSPS Embedded Server and upload the module.
  4. Test the documents:
    1. Log in to the Process Application in your browser.
    2. In the document with the position evaluator, enter the years-of-experience data and get the resulting level.
    3. Now open the document with the decision table, and edit the values and add a new rule.
    4. Open the evaluator document again and enter the years-of-experience data and get the updated resulting level.