| Both sides previous revision Previous revision Next revision | Previous revision |
| docs:3000_rule_language:0400_rule_language [2022/09/01 01:23] – ↷ Links adapted because of a move operation administrator | docs:3000_rule_language:0400_rule_language [2025/06/12 03:59] (current) – Change to AwareIM aware_support3 |
|---|
| "AND" PredicateExpression() | "AND" PredicateExpression() |
| )* | )* |
| </code> | </code> |
| |
| |
| ==== Function ==== | ==== Function ==== |
| |
| A function performs some calculation and returns the result as a Literal. There are a number of built-in functions that //**Aware IM**// supports. New functions can be plugged in as well (see "Aware IM Programmer’s Referefence"). A function may or may not have parameters. Parameters of a function must be Arithmetic Operations. IF a function does not have parameters then it can be referred to by name only. IF a function has parameters, they are listed after the function’s name and enclosed in brackets. Parameters are separated by the comma symbol. Examples of functions: | A function performs some calculation and returns the result as a Literal. There are a number of built-in functions that //**AwareIM**// supports. New functions can be plugged in as well (see "AwareIM Programmer’s Referefence"). A function may or may not have parameters. Parameters of a function must be Arithmetic Operations. IF a function does not have parameters then it can be referred to by name only. IF a function has parameters, they are listed after the function’s name and enclosed in brackets. Parameters are separated by the comma symbol. Examples of functions: |
| |
| * ''CURRENT_DATE'' - function with no parameters | * ''CURRENT_DATE'' - function with no parameters |
| * ''MONTH_DIFFERENCE (Account.OpeningDate, Account.ClosingDate)'' – function with two parameters | * ''MONTH_DIFFERENCE (Account.OpeningDate, Account.ClosingDate)'' – function with two parameters |
| |
| The complete list of built-in functions supported by //**Aware IM**// is provided in the [[a_f:f:xx_function_list|here]]. | The complete list of built-in functions supported by //**AwareIM**// is provided in the [[a_f:f:af|here]]. |
| |
| |
| <callout type="primary" icon="true" title="note"> | <callout type="primary" icon="true" title="note"> |
| SUM, MIN, MAX, AVG calculations must not use attributes of the Reference type, for example the following expression is not valid:\\ ''SUM Account.Transactions.Amount''\\ IF aggregate of the referred object is required as in the example above, the following expression must be used:\\ ''SUM Transaction.Amount WHERE (Transaction IN Loan.Transactions)''</callout> | SUM, MIN, MAX, AVG calculations must not use attributes of the Reference type, for example the following expression is not valid:\\ ''SUM Account.Transactions.Amount''\\ IF aggregate of the referred object is required as in the example above, the following expression must be used:\\ ''SUM Transaction.Amount WHERE (Transaction IN Loan.Transactions)''</callout> |
| <callout type="primary" icon="true" title="note"> COUNT operation MUST only use the name of the business object, which it counts, for example, \\ <code aim>COUNT Account or COUNT Account WHERE (Account.State='Open')</code>. </callout> | <callout type="primary" icon="true" title="note"> COUNT operation MUST only use the name of the business object, which it counts, for example, \\ <code aim>COUNT Account or COUNT Account WHERE (Account.State='Open') </code>. </callout> |
| <callout type="primary" icon="true" title="note"> Using references is not allowed, for example the following construct is invalid:<code aim>COUNT Account.Transactions </code>The valid expression that achieves the desired result is:<code aim>COUNT Transaction WHERE (Transaction IN Account.Transactions)</code> | <callout type="primary" icon="true" title="note"> Using references is not allowed, for example the following construct is invalid:<code aim>COUNT Account.Transactions </code>The valid expression that achieves the desired result is:<code aim>COUNT Transaction WHERE (Transaction IN Account.Transactions) </code> |
| </callout> | </callout> |
| |
| Examples of valid relational expressions: | Examples of valid relational expressions: |
| |
| <code aim> Account.State = 'CLOSED'</code> | <code aim>Account.State = 'CLOSED' </code> |
| <code aim> Account.Balance < Account.Type.MinBalance + 100</code> | <code aim>Account.Balance < Account.Type.MinBalance + 100 </code> |
| |
| |
| It checks whether an arithmetic operation (usually an attribute of a business object) starts with (or ends with or contains) the specified arithmetic operation that produces a string (usually a string literal), for example: | It checks whether an arithmetic operation (usually an attribute of a business object) starts with (or ends with or contains) the specified arithmetic operation that produces a string (usually a string literal), for example: |
| |
| <code aim> Account.Name STARTSWITH 'John' </code> | <code aim>Account.Name STARTSWITH 'John' </code> |
| <code aim> Account.Name ENDSWITH 'Smith' </code> | <code aim>Account.Name ENDSWITH 'Smith' </code> |
| <code aim> Account.Name CONTAINS 'it' </code> | <code aim>Account.Name CONTAINS 'it' </code> |
| |
| |
| |
| - ''EXISTS'' expression is very similar to [[docs:2000_concepts:0800_data_processing:0100_rule_evaluation:0200_aggregate_operations|Aggregate Operation]], except that the result of the ''EXISTS'' expression is true or false, rather than arithmetic value. The syntax and usage are the same as that of the ''Aggregate Operation''. The ''EXISTS'' operation checks whether there are any instances of the specified business object in the system, for example, | - ''EXISTS'' expression is very similar to [[docs:2000_concepts:0800_data_processing:0100_rule_evaluation:0200_aggregate_operations|Aggregate Operation]], except that the result of the ''EXISTS'' expression is true or false, rather than arithmetic value. The syntax and usage are the same as that of the ''Aggregate Operation''. The ''EXISTS'' operation checks whether there are any instances of the specified business object in the system, for example, |
| * <code aim> IF EXISTS Account THEN ...</code> | * <code aim>IF EXISTS Account THEN ... </code> |
| * <code aim> IF EXISTS Account WHERE (Account.State = 'Open') THEN ...</code> | * <code aim>IF EXISTS Account WHERE (Account.State = 'Open') THEN ... </code> |
| - ''IN'' expression checks whether a particular instance of a business object is in the reference list of another object. For example, | - ''IN'' expression checks whether a particular instance of a business object is in the reference list of another object. For example, |
| * <code aim> IF Transaction IN Account.Transactions THEN ...</code> | * <code aim>IF Transaction IN Account.Transactions THEN ... </code> |
| |
| It is possible to use a special expression ''LOGGED_IN_USERS'' instead of the list of references. This will check if the specified user is logged in, for example: | It is possible to use a special expression ''LOGGED_IN_USERS'' instead of the list of references. This will check if the specified user is logged in, for example: |
| |
| <code aim> FIND SystemUser WHERE SystemUser.LoginName='John' </code> | <code aim>FIND SystemUser WHERE SystemUser.LoginName='John'</code> |
| |
| <code aim> IF SystemUser IN LOGGED_IN_USERS THEN | <code aim>IF SystemUser IN LOGGED_IN_USERS THEN DISPLAY MESSAGE 'John is logged in' </code> |
| DISPLAY MESSAGE 'John is logged in' </code> | |
| | |
| ===== List expression ===== | ===== List expression ===== |
| In other words an attribute identifier is followed by the keyword IN and then is followed by one or more literals. Any kind of literal is valid. Some examples of valid list expressions: | In other words an attribute identifier is followed by the keyword IN and then is followed by one or more literals. Any kind of literal is valid. Some examples of valid list expressions: |
| |
| <code aim> Account.State IN 'Open', 'Closed' </code> | <code aim>Account.State IN 'Open', 'Closed' </code> |
| |
| <code aim> Account.Balance IN 1000, 2000, 3000</code> | <code aim>Account.Balance IN 1000, 2000, 3000 </code> |
| |
| |
| |
| |
| <code aim> Account.Balance BETWEEN 10000 AND 20000;</code> | <code aim>Account.Balance BETWEEN 10000 AND 20000; </code> |
| |
| <code aim> Transaction.Amount BETWEEN Account.Balance/2, 5000</code> | <code aim>Transaction.Amount BETWEEN Account.Balance/2, 5000 </code> |
| |
| <callout type="primary" icon="true" title="note">both ranges are inclusive</callout> | <callout type="primary" icon="true" title="note">both ranges are inclusive</callout> |
| |
| |
| - AttributeIdentifier () ''WAS CHANGED'' – checks if an attribute has been changed. For example, <code>IF Account.State WAS CHANGED THEN ...</code>The entire object can be checked as well – in this case all attributes of the object are checked for changes, for example <code aim> IF Account WAS CHANGED</code> | - AttributeIdentifier () ''WAS CHANGED'' – checks if an attribute has been changed. For example, <code aim>IF Account.State WAS CHANGED THEN ... </code>The entire object can be checked as well – in this case all attributes of the object are checked for changes, for example <code aim>IF Account WAS CHANGED </code> |
| - AttributeIdentifier () ''WAS CHANGED TO'' Literal () – checks if an attribute has been changed and the new value is equal to the specified value, for example, <code aim> IF Account.State WAS CHANGED TO 'Open' THEN ...</code> | - AttributeIdentifier () ''WAS CHANGED TO'' Literal () – checks if an attribute has been changed and the new value is equal to the specified value, for example, <code aim>IF Account.State WAS CHANGED TO 'Open' THEN ... </code> |
| - AttributeIdentifier () ''WAS CHANGED BY ANY USER'' - deprecated. Functionally equivalent to ''WAS CHANGED''. | - AttributeIdentifier () ''WAS CHANGED BY ANY USER'' - deprecated. Functionally equivalent to ''WAS CHANGED''. |
| |
| The ''WAS CHANGED'' expression can be used for reference lists as well as for ordinary attributes. The ''WAS CHANGED'' expression for lists indicates whether there were any references changed or removed from the list compared to the last stable version (see the "[[docs:2000_concepts:0800_data_processing:0100_rule_evaluation:0900_evaluation_was_changed_expressions|Evaluation of WAS CHANGED expressions]]" section for a more detailed explanation). For example, | The ''WAS CHANGED'' expression can be used for reference lists as well as for ordinary attributes. The ''WAS CHANGED'' expression for lists indicates whether there were any references changed or removed from the list compared to the last stable version (see the "[[docs:2000_concepts:0800_data_processing:0100_rule_evaluation:0900_evaluation_was_changed_expressions|Evaluation of WAS CHANGED expressions]]" section for a more detailed explanation). For example, |
| |
| <code aim> IF Account.Transactions WAS CHANGED THEN ...</code> | <code aim>IF Account.Transactions WAS CHANGED THEN ... </code> |
| |
| |
| It is possible to identify more precisely how a reference list has been changed and perform actions based on the values of the objects that have been added or removed from the list. The ''WAS ADDED TO'' expression can be used to check whether any objects have been added to the list and the ''WAS REMOVED FROM'' expression can be used to check whether the objects have been removed from the list. To refer to the objects that have been added or removed, the Added and Removed instance prefixes can be used respectively (see the "[[docs:2000_concepts:0800_data_processing:0100_rule_evaluation:0800_context_rule_execution:0200_instance_prefixes|Instance Prefixes]]" section. For example, | It is possible to identify more precisely how a reference list has been changed and perform actions based on the values of the objects that have been added or removed from the list. The ''WAS ADDED TO'' expression can be used to check whether any objects have been added to the list and the ''WAS REMOVED FROM'' expression can be used to check whether the objects have been removed from the list. To refer to the objects that have been added or removed, the Added and Removed instance prefixes can be used respectively (see the "[[docs:2000_concepts:0800_data_processing:0100_rule_evaluation:0800_context_rule_execution:0200_instance_prefixes|Instance Prefixes]]" section. For example, |
| |
| <code aim> IF Transaction WAS ADDED TO Account.Transactions THEN | <code aim>IF Transaction WAS ADDED TO Account.Transactions THEN |
| INCREASE Account.Balance BY AddedTransaction.Amount</code> | INCREASE Account.Balance BY AddedTransaction.Amount </code> |
| |
| <code aim> IF Transaction WAS REMOVED FROM Account.Transactions THEN | <code aim>IF Transaction WAS REMOVED FROM Account.Transactions THEN |
| REDUCE Account.Balance BY RemovedTransaction.Amount</code> | REDUCE Account.Balance BY RemovedTransaction.Amount </code> |
| |
| IF the list itself hasn’t changed, but an element belonging to the list has been, then this situation can be checked using the following expression: | IF the list itself hasn’t changed, but an element belonging to the list has been, then this situation can be checked using the following expression: |
| |
| |
| <code aim> IF Transaction FROM Account.Transactions WAS CHANGED THEN | <code aim>IF Transaction FROM Account.Transactions WAS CHANGED THEN |
| INCREASE Account.Balance BY (ChangedTransaction.Amount – OLD_VALUE(Transaction.Amount))</code> | INCREASE Account.Balance BY (ChangedTransaction.Amount – OLD_VALUE(Transaction.Amount)) </code> |
| |
| |
| |
| |
| - AttributeIdentifier () ''IS UNDEFINED'' – checks whether an attribute is undefined, for example, <code aim> IF Account.State IS UNDEFINED THEN ...</code> | - AttributeIdentifier () ''IS UNDEFINED'' – checks whether an attribute is undefined, for example, <code aim>IF Account.State IS UNDEFINED THEN ... </code> |
| - AttributeIdentifier () ''IS DEFINED'' – checks whether an attribute is defined, for example, <code aim> IF Account.State IS DEFINED THEN ...</code> | - AttributeIdentifier () ''IS DEFINED'' – checks whether an attribute is defined, for example, <code aim>IF Account.State IS DEFINED THEN ... </code> |
| |
| |
| The ''IS NEW'' expression checks whether the particular object specified in the expression is being created, for example | The ''IS NEW'' expression checks whether the particular object specified in the expression is being created, for example |
| |
| <code aim> IF NOT (Message IS NEW) THEN PROTECT Message.Subject</code> | <code aim>IF NOT (Message IS NEW) THEN PROTECT Message.Subject </code> |
| |
| |
| In this example the ''Subject'' attribute of the ''Message'' object is protected if the object already exists in the system. | In this example the ''Subject'' attribute of the ''Message'' object is protected if the object already exists in the system. |
| |