1. Rules

    Article: AN0001642Updated:

    Rules can be defined in a class or query. Rules enable formatting of displayed data, perform checks before display or saving data, send notifications etc.

    Each rule has Event type, that says when something shall happen and Action type, which says, what shall happen.

    You can define whatever number of rules and they will be evaluated in order according to the property Order. The value Order does not need to be unique. However, in such a case rules with the same order will be executed in a random order.

    By means of property Enabled you can disable the rule temporarily.

    Insert rule description in the property Functional description. If the description is in this field and not in the script itself, the processing will be accelerated.

    Event type

    Following table displays list of all the event types, to which you can respond in the model.

    Name
    Before new record detail display
    Before existing record list display
    Before new record saving
    After new record saving
    Before existing record saving
    After existing record saving
    Before record deletion
    Before saving new template
    Before saving existing template

    Action type

    Name Description
    Send notification Send notification depending on data in the particular record.
    Start workflow Workflow can be started for new or updated record.
    Set formatting You can set font and background colours, bold or italics for particular columns. You can also set background colour for the whole row.
    Set or calculate value You can set formula for value calculation for each column.
    Condition

    It is used before saving and deleting the record, when the entered condition is evaluated. If it is not met, the record will not be saved/deleted and an error message is displayed.

    By means of this rule you can easily add integrity checks of data entered by the user into class.

    Start script In this rule you can add whatever extension by means of scripting. You can start a procedure, import, export, worflow etc.

    You can use following objects in condition script:

    Object Description When
    OG Common object for scripts.  
    OGActualDataRow Current data record (type DataRow).  
    OGOldDataRow Previous data record (type DataRow).

    Before saving current record

    After saving current record

    OGDataParent Class object.  
    OGSaveOption Object for controlling way of record saving.  

    Rule Start script

    It is possible to change all the columns of the class record in the rule, except for system columns (these are set by the system itself). Script is considered a secured part of the system and no restrictions for column update are applied to it.

    You can solve also data initialization at creation of a new record in the script.

    You can use following objects in the script:

    Name Description When
    OG Object that is common for all scripts.  
    OGActualDataRow Current DataRow.  
    OGOldDataRow Original unchanged DataRow. Before and after saving an existing record
    OGActualMessage Object for setting a message returned from the rule.  
    OGModel Model object.  
    OGDataParent Class object.  
    OGSaveOption Object for setting saving parameters.  
    OGForm Objekt pro práci s formulářem. Before displaying detail of a new record

    By means of object OGActualMessage you can return a message that will be displayed to user after the rule finishes. Pro hlášení můžete použít metody SetError, SetInfo a SetSuccess. By using method SetSuccess in rule After saving a new/existing record you will suppress displaying standard message about record saving.

     

    If the rules has Event type set to Before saving new/existing record, then there is displayed setting Check the mandatory columns first.

    This enables to create a rule that runs before of after check of mandatory columns. In case of rules before the check you can fill in mandatory columns that were not filled in. The rule after the filling can then safely refer to values from mandatory columns.

    Before displaying new record in detail

    You can define a default value for particular columns in this rule. 

    You can define the default value as ID of the referenced record for the column type Value from a referenced class (however, this is not recommended due to portability to another instances) or as a text code enclosed in apostrophes. This code has to be in the referenced class in a text column with code code. There is upper and lower case distinguished in the value. If the ID or code do not exist in the referenced class, the settings are ignored.

    Separate the values by comma in case of multiple references. If there are more values defined for a simple reference, the first one is used and the other are ignored.

    Example:     'assigned'   'assigned,new,closed'

     

    You can define the default value as a text code with code of the class enclosed in apostrophes for the column type Value from a referenced class (various casses). This code has to be in the referenced class in a text column with code code. There is upper and lower case distinguished in the value. If the ID or code do not exist in the referenced class, the settings are ignored..

    Separate the values by comma in case of multiple references. If there are more values defined for a simple reference, the first one is used and the other are ignored.

    Format:     'class_code:record_code'

    Example:     'status:assigned'   'status:assigned,type:all'

    Order of record initialization when displaying a new record on DataDetail.aspx

    Display of a new record and its initialization can be influenced from several locations. Following overview displays order of calls:

    1. default values defined in columns
    2. values from a template - if it is used
    3. sequences in columns
    4. rules Set value and Script - they are processed according to the order defined in the rule
    5. script from class
    6. initialization via URL

    It is not recommended to use all the possibilities at the same time - the solution would not be clear. Different options are suitable for different scenarios. Therefore, it is useful to think abot their use.

    Rules for templates

    Rules for templates are used to adjust record that is saved into the template. At the tme when the rule is applied you can delete values from columns from the DataRow (OGActualDataRow) that you do not want to have in the template. You can use for it functions from DataRow ClearColumn, RemoveColumn, RemoveColumnsExceptThose.

×