Page tree

Versions Compared

Key

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

...

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

...