Event Blocks - Templates

WorkWithPlus provides the possibility to insert event blocks in any template. This is useful when you need to insert some code repetitively in many objects, in some event or sub.

In order to do this, you have to insert a node within the Events & Subs node of the correspondent template:

TemplatesEventBlocks_img10

The Challenge

The customer needs to mention in the title of the form of every transaction the action that the end-user is doing(inserting, updating, or deleting a record).

As it is a code that you have to insert in every transaction, WorkWithPlus provides a mechanism for doing this massively: create a block code in Start Event, position bottom which contains the following code:

TemplatesEventBlocks_img00100

You can copy the following code:

Do case
  case &Mode = TrnMode.Insert
       Form.Caption += " (Insert)"
  case &Mode = TrnMode.Update
       Form.Caption += " (Update)"
  case &Mode = TrnMode.Delete
      Form.Caption += " (Delete)"
EndCase

Tip: The Include property (present only for Transaction Templates) allows you to define if the block must be included only once (Once) or if it must be added when a certain condition is met in an attribute (Once per matching attribute).

Then, save the WorkWithPlus Settings and select "Yes" in the following message so the "Update Instances" process, in order to propagate the changes made in the template, is executed: 

TemplatesEventBlocks_img00101

Run the application and go to every transaction at runtime in order to check that the new behaviour was added:

TemplatesEventBlocks_img03

Finally, open the transaction and check that the block code was added in the Start event, inside the code generated automatically by WorkWithPlus.

TemplatesEventBlocks_img02

Advanced:

You can learn more at Event Blocks

Summary

Well done! You should now be able to:

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