Automatic Rules - Transaction

The Challenge

The customer requires auditing some information for each created or updated record. The information to store is the following:

  • Date of creation
  • The user who created the record
  • Date of modification
  • The user who modified the record. 

To achieve this, the transactions contain four attributes in order to save the information mentioned above. Now, is necessary to load information to these attributes with rules (one rule for each attribute). Probably in the future, the application will contain other transactions that will contain auditing attributes.

WorkWithPlus provides a mechanism in order to add rules which need to be added for multiple transactions (for certain attributes), and just add it once in the KB: Automatic Rules

Add a Rules node in the transaction template, and add the following automatic rules:

TransactionFeaturesAutomaticRules_img01

CreateDate

TransactionFeaturesAutomaticRules_img02

CreateUser

TransactionFeaturesAutomaticRules_img03

UpdateDate

TransactionFeaturesAutomaticRules_img04

UpdateUser

TransactionFeaturesAutomaticRules_img05

Execute the action ‘Update Instances’ over the transaction template so that WorkWithPlus propagates the changes made in the templates into the instances (this process will be explained further in the training).

Open Company transaction and go to Company’s WorkWithPlus instance in order to verify that the rules were added automatically:

TransactionFeaturesAutomaticRules_img07

You can see that the rules were created in the "Rules" tab:

TransactionFeaturesAutomaticRules_img08

Run the application, create a record, and verify that the creation date was automatically updated. Then make the same process for modifying a record.

Tip: you should store the logged used once the login was done. To do this, you can edit the "GAMExampleLogin" panel by adding the following in the "Enter" event:

LoadWWPContext(&WWPContext)        
&WWPContext.UserName=&UserName
SetWWPContext(&WWPContext)

Summary

Well done! You should now be able to:

  • Add an Automatic Rule in order to automatize the KB behaviour
  • Use the "Update Instances" process in order to propagate the changes made in the template