Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents
maxLevel1

Creating Vocabularies

Image Added

Vocabularies contain all the information which can be used in conditions and updated in actions. For example: The form field and the datasource field values we use in conditions, and the form field and page (tabs) enabled and visible properties we can set in actions.

...

There is currently no need or use case to change the default values when generating a vocabulary.Image Removed

The Generate Vocabulary window creates a vocabulary file with the same name as the window or frame and the .ecore extension. Currently the file is saved out to the pasoe PASOE temp directory. After the vocabulary file is generated, copy the file to your workspace (see file and directory structure).

...

In addition, the layout designer sets the RulesBehaviour and RulesMetadata properties for the window and the frame. These properties contain metadata and advanced options. There's currently no need or use cases to change these properties except when removing a ruleflow rule flow by deleting or setting an empty JSON object "{}".

...

  • Open the Corticon.js Studio in the root rules directory, in the customer webui/Rules directory.

  • All the rule files for a window or frame should be placed in a single directory with the same name (inside the correct module directory, in the Ruleflows directory).

  • All the rule files should start with the same name as the window or frame (there is only one vocabulary and one workflow files so they should have the same name as the window or frame).

  • Every rule sheet file should have a different suffix like _IsEnabled, _IsVisible, _Pages etc. (see rule sheet design).
    For example: EntscheidDetailWindow_IsEnabled.ers

  • Rule test files should start with the same name as their rule sheet including the suffix plus _Test or _Test<number> for multiple rule tests (see rule test design).
    For example: EntscheidDetailWindow_isEnabled_Test.ert

  • Generate the .js files directory in the root rules directory which is also the default location in the Corticon Generate Ruleflow dialog-box.

...

  • Place rules in the frame rule flow whenever you can and the window rule flow whenever you have to, for the purpose of dividing the rules into many simple frame rule flows instead of one big and complicated window rule flow (see creating vocabularies).

  • Divide the rules into the following rule sheets and rule sheet names (unless they have no rules. There's no need for empty rule sheets) -

    • <window or frame>_Fixed.ers - Fixed property settings.
    • <window or frame>_IsEnabled.ers - Rules for enabling form fields.
    • <window or frame>_IsVisible.ers - Form fields visibility rules.
    • <window or frame>_Pages.ers - Pages (tabs) visiblity rules and enabling or disabling pages.
    • <window or frame>_Messages.ers - Message rules (errors, warnings and info messages).

  • Complicated rules with conditions containing more than 5 to 10 fields and more than 5 to 10 combinations should be put in a separate rule sheets with their own descriptive name suffix.
    For example: EntscheidDetailBasisFrame_IsUnUpdatable.ers

  • Use the vocabulary fields not expressions in the condition and action panes unless you have to.
    For example: In the condition pane, do not use EntscheidDSO.Visum_Dat = null. Use EntscheidDSO.Visum_dat and null in the cell value.
    For example: In the action pane, do not use EntscheidDSO.isAvailable = true. Use EntscheidDSO.isAvailable and T in the cell value.

  • Beware of NULL's. Datasource field values are null when the record is not available so you may also want to add isAvailable and T cell value to your condition.
    For example: add EntscheidDSO.isAvailable and T cell value, to EntscheidDSO.Visum_dat and null cell value.

  • A specific property (like a form field is enabled property or any other property) must be set in one place and one place only. The property must be set in one rule sheet covering all the combinations. In either the frame or window rules but never both. Setting the same property in different rule sheets increases the risk of conflicts.

  • Use the default action column whenever possible to decrease the number of combinations and simplify rule sheets.
    For example: if you set the default for the is enabled property to false then you only need to specify the condition combination when it is true.

  • Use an AND condition in combination with the default column instead of an OR condition for setting properties to decrease the number of combinations and simplify rule sheets (because AND conditions use a single combination column while OR conditions use multiple combination columns). 

  • The fixed rule sheet should only be used for properties that have a fixed or constant value and should not be used for default values.
    For example: if the specification says this form field is always enabled.

  • The fixed rule sheet can also be used for setting custom properties by calling the custom JavaScript functions to fetch values (see incorporating code).

  • In the messages rule sheet, place the message text values in the cell action column and use the cellValue for the message parameter.
    For example: Message.new[type='info', entity='EntscheidDetailWindow', message=cellValue]

  • Every rule action should have a rule statement with a simple description (the descriptions will not be shown to the user) used internally for debugging and understanding what rules were triggered (see rule tests design). No need to add a rule statement for the default column (column 0).

  • Avoid dependencies - Avoid using calculated values from rule sheets. Only use values coming from the vocabulary.
    With the exception of Custom properties set with JavaScript functions (see incorporating code).

...

Rule tests also show you the rule statements of the rules that were triggered when running the test sheet to further help debug and understand the output.

You cannot have multiple separate different tests with different conditions in a single test sheet and they must be separated into separate test sheets. Alternatively, use a single test sheet which with conditions that triggers multiple rules.

Rule tests need to be incorporated and run as part of the build and pipeline unit tests.

...

  • Every rule sheet should have a rule test (except for the fixed rule sheet) with the same name of their rule sheet and a _Test suffix.
    For example: EntscheidDetailWindow_IsEnabled_Test.ert

  • Include the entities used for conditions and actions. If the entities used for condition are not included then you cannot set them. If the entities used for actions are not included then you will not see their changes. Except for entities the action creates new instances, like messages. New instances will be included.

  • Remove unused fields that have no conditions when copying entities to the input column, to keep the rule tests simple and readable (keeping in mind that some forms and datasources can have tens or even hundreds of fields).

  • Check all the rules work including cases when they should not work.

  • Currently only use a single object instance in your test sheet. If you need multiple instances, you most likely need another test sheet (tab).
    For example: do not use multiple instances of EntscheidDSO with different values to test multiple cases. Use multiple test sheets with a single EntscheidDSO in each one.

Note that at runtime Corticon logging can be turned on by setting Corticon.debug = true that will console log the rule triggers, execution, messages (rule statements), payload and result.

Rule Flows


Even though the rule sheets have no dependencies by default (except for special cases) and there is no need to connect them, it is still considered a best practice and you should always connect the rule sheets so the order of execution is clear.

...

The window and frame names are unique so there is no risk of conflicts.

DynSelect

...

Settings

Guidelines

  • If there are any related fields that should be updated when a dynSelect value is changed in a form or calculated fields in business entities then they should be added to the dynSelect mapping so the correct values are available to Corticon.

    This guideline is true when using Corticon as it is when writing TypeScript.

...

To run asynchronous code like backend calls, create a regular TypeScript event handler file that sets custom properties in the screen akEvent payload property and then calls the frame or window controller callRules() method to execute the screen rules.

Custom Events

The framework provides several entry points in the Corticon execution process:

  • EventBeforeRuleExecution: will be run before the rules are executed
  • EventAfterRuleExecution: will be run after the rules are executed
  • EventAfterRuleApply: will be run after the rules execution payload is processed
  • EventAfterRuleDisplay: will be run after the messages are displayed

The events can be specified from the Corticon 'RulesBehavior' attribute, using properties with the same name as the event.
The event format itself is identical with the other framework events, with 'self' referencing the rules' main window.
The payload is made accessible through the window's akEvent property. (akEvent.rulesExecution.payload)

Custom Properties

As of SWAT 21.14, the vocabularies will be generated with a new custom screen properties entity. (_CustomData.CustomScreenProperties)
By default the entity will be empty, it won't contain any properties.
To add screen properties, the 'RulesBehavior' attribute now accepts a new property 'CustomPropertyObjects', which will contain a comma-separated list of MATCHES patterns for repository data fields.
(ex. "field1,field2,fields*", which will match objects 'field1', 'field2' and all objects starting with 'fields')
All matching data field objects will be processed and a corresponding property will be added to the custom screen properties entity.
The role of this new entity is to provide an easy and accessible way to add custom properties to a vocabulary without risk of losing them on regeneration. (as it happens now for manually added ones)

The custom properties can be assigned from the Corticon custom events and to facilitate this, the following helper functions have been made available:

Code Block
languagejs
themeMidnight
titleHelper functions
linenumberstrue
/**
 * Gets an entity from a given payload
 * @public
 * @static
 * @memberOf Corticon
 * @param {Object} payload The payload
 * @param {string} entityName The entity name
 * @returns {Object} The entity object from the payload or undefined if not found
 */
Corticon.getCustomScreenPropertiesFromPayload(payload);

/**
 * Gets the 'CustomScreenProperties' entity from a given payload
 * @public
 * @static
 * @memberOf Corticon
 * @param {Object} payload The payload
 * @returns {Object} The entity object from the payload or undefined if not found
 */
Corticon.getEntityFromPayload(payload, entityName);

Resources

...