Automatic Rules

WorkWithPlus provides the possibility to insert parametric Rules which will be added to transactions whether they accomplish certain regular expression or some condition property.

The main purpose of Rules is to allow user inserting Rules in WorkWithPlus Configuration that will apply for most of transaction instances, and all transaction will inherit these Rules by default when applying the pattern the first time or when executing Update Instances action.

In order to define a Rule it is necessary to specify the regular expression or the properties that will define to which attributes the rule will be added, and the rule itself which will be able to contain tags like <TRN_NAME>, <TRN_DESCRIPTION>, <ATT_NAME> and <ATT_DESCRIPTION>.

For example, let's suppose we have Person and Country transactions.

Person transaction has the conventional attributes (Id, Name, Lastname, Phone, etc.) but also has PersonCreateDate, PersonCreateUser, PersonUpdatedDate and PersonUpdatedUser which will have to be updated automatically by transaction rules each time a change is made or when it creates. So, Person transaction has the following structure:

AutomaticRulesImg01

The same happens with Country transaction, because it is a requirement for the application to record information about user and date that a change is made, an this transaction has the following structure:

AutomaticRulesImg02

The code that developer will have to insert in rules for each transaction that needs to record its last user and date update or creation is very similar, and repetitive. An alternative to avoid inserting in every transaction those rules, is by using Rules feature. 

We would have to insert in Transaction object of Instance Template the following rules:

AutomaticRulesImg03

We can visualize below the properties that each of these rules have set:

Rule: SetCreateDate

This rule will assign to all attributes that contains 'CreateDate' within its name (Regular Expression) the result of Now() function on afterValidate event if it is an insertion. The name of the rule is to identify it within pattern instance.

AutomaticRulesImg04

Rule: SetCreateUser

This rule will assign to all attributes that contains 'CreateUser' (Regular Expression) the value of Context's User on afterValidate event if it is an insertion.

AutomaticRulesImg05

Rule: SetUpdateDate

This rule will assign to all attributes that contains 'UpdateDate' (Regular Expression) the result of Now() function on afterValidate event if user is updating the record.

AutomaticRulesImg06

Rule: SetUpdateUser

This rule will assign to all attributes that contains 'UpdateUser' (Regular Expression) the value of Context's User saved on afterValidate event if user is updating the record.

AutomaticRulesImg07

Rule: noAcceptUpdate_Create_Attributes

This rule will set the noaccept rule to all attributes that contains 'Update' or 'Create' next to 'User' or 'Date'.

AutomaticRulesImg08

Then we create default instance for Person transaction, and we can appreciate that it contains the rules created in Instance Template:

AutomaticRulesImg09

If we save the object, we could visualize that the rules were added successfully:

AutomaticRulesImg10

The rules were added for the attributes that accomplish the regular expression within Person transaction.

Then we create default instance for Country transaction, and we can appreciate that it contains the rules created in Instance Template:

AutomaticRulesImg11

Finally we save the object, and visualize that the rules were added successfully:

AutomaticRulesImg12