Event Blocks

WorkWithPlus provides the possiblity to insert event blocks in any template (transaction template or web panel template).

This is useful when you need to insert some code repetively in many objects, in some event or sub.

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

For example, in the Web panel template named 'Create Data' there is created two Events & Subs:

EventBlocksImg01

And the properties associated to Sub 'Show Messages' are:

EventBlocksImg02

General Properties

Block Name:

Block´s name. This property is required to identify it on the instance. 

Wrapping Tag:

Tag that will be wrapping the defined code block. For example, you can use a "web" tag in order to add code related to controls within the form.

Type:

Type of the block. The options are Event or Sub.


Position:

Allows you to determine whether you want to insert the block code on top of the code created by the pattern or on bottom of it.
 

Code block with position Bottom

EventBlocksImg03

EventBlocksImg04

Code block with position Top

EventBlocksImg05

EventBlocksImg06
 

Event/Sub Name:

Event or sub where the code will be located. It can be a user event/sub or some standard event like Start, Refresh, Enter. If it is a user event/sub it has to be surrounded with ' '.   


Code:

It is the code to add in the event/sub. It will be transcribed as it is to the event/sub defined.
 

In the code, you can include the following tags:

    If the block is added in a web panel template:

  • <OBJ_NAME>: Name of the object (Web Panel)
  • <OBJ_DESCRIPTION>: Description of the object (Web Panel)

    If the block is added in a transaction template (any object, like Selection for example):

  • <TRN_NAME>: name of the transaction associated to the instance
  • <TRN_DESCRIPTION>: description of the transaction associated to the instance
  • <ATT_NAME> and <ATT_DESCRIPTION> are also tags available in this scenario, but just when the property 'Include' of this node has the value 'Once per matching attribute', which is mentioned below in the same document.
  • <PK_LIST>: it will replace the tag with all the attributes that compose the primary key of the transaction, each attribute separated by comma to the next one.
     

    For example, with the folllowing EventBlock:

    EventBlocksImg07

    After making Update Instance to History transaction, which has the following structure:

    EventBlocksImg08

    The added code is the following:

    EventBlocksImg09

  • <PK_VAR_LIST>: it will replace the tag with a variable for each attribute that compose the primary key of the transaction, each variable separated by comma to the next one.
    The same example above, but instead of using <PK_LIST> use <PK_VAR_LIST> will have the following result in History transaction:
    EventBlocksImg10

  • <PK_LIST_SERIALIZED>: it will replace the tag with all the attributes that compose the primary key of the transaction, each attribute separated by pipe to the next one.
    EventBlocksImg12
    In the transaction named History (mentioned above), it will add the following code:
    EventBlocksImg11

  • <PK_VAR_LIST_SERIALIZED>: it will replace the tag with a variable for each attribute that compose the primary key of the transaction, each variable separated by pipe to the next one.
    The same example above, but instead of using <PK_LIST_SERIALIZED> use <PK_VAR_LIST_SERIALIZED> will have the following result in History transaction:
    EventBlocksImg13

 The following tags can be used only on GridTab Templates:

  • <GRID_TRN_NAME>: returns the related transaction name on a View GridTab.
  • <GRID_TRN_DESCRIPTION>: returns the related transaction description on a View GridTab.
  • <GRID_TRN_PK_LIST>: it will replace the tag with all the attributes that compose the primary key of the related transaction on a View GridTab separated by comma to the next one.
    Example of this Tag used in a GridTab related to History transaction (mentioned above)

     Procedure1(HistoryYear, HistoryMonth, HistoryDay)
     
  •   <GRID_TRN_PK_LIST_SERIALIZED>: it will replace the tag with all the attributes that compose the primary key of the related transaction on a View GridTab separated by pipe to the next one.
    If you have a block code in GridTab which uses this tag as the image shown below:
    EventBlocksImg14
    And you have a transaction which contains a GridTab and the block code (in this case the related transaction is History, which its PK is HistoryYear, HistoryMonth and HistoryDay
    EventBlocksImg15
    The Tag will be replaced as it is shown below:
    &Description = HistoryYear.ToString().Trim() + !'|' + HistoryMonth.ToString().Trim() + !'|' + HistoryDay.ToString().Trim()
  • <GRID_TRN_PK_VAR_LIST>:it will replace the tag with a variable for each attribute that compose the primary key of the related transaction on a View Tab, each variable separated by comma to the next one.
  • <GRID_TRN_PK_VAR_LIST_SERIALIZED>:it will replace the tag with a variable for each attribute that compose the primary key of the related transaction on a View Tab, each variable separated by pipe to the next one.
    The example is analogous to the one mentioned with the tag <GRID_TRN_PK_LIST_SERIALIZED>, but with variables instead of attributes:
    &Description = &HistoryYear.ToString().Trim() + !'|' + &HistoryMonth.ToString().Trim() + !'|' + &HistoryDay.ToString().Trim()
  • <GRID_TRN_NULLVALUE_PK_LIST>: it will replace the tag with the nullvalue of all attributes that compose the primary key of the related transaction on a View GridTab separated by comma to the next one.
  • <GRID_TRN_NULLVALUE_PK_EXCEPT_MAIN_TRN_PK_LIST>: it will replace the tag with the nullvalue of all attributes that compose the primary key of the related transaction on a View GridTab except for the Main transaction primary key.
  • <NULLVALUE_PK_LIST>: it will replace the tag with the nullvalue of all attributes that compose the primary key of the transaction.

The Event Blocks can be added for Transaction, Selection, Export procedure, ExportReport procedure, LoadAudit procedure, Prompt, View, Tabs of View object and WebPanels.

When the Event Blocks are added in an object within a transaction template (Transaction, Selection, Prompt, etc.), a new property Named 'Include' appears:

EventBlocksImg16

The property 'Include' specifies whether this block code will be included just once in the specified event or subroutine, or if it will be added once per attribute that matches the restrictions defined below.

When the property 'Include' has the value 'Once per matching attribute', in the code you can use the tags <ATT_NAME>, <ATT_DESCRIPTION> as well as the ones that does not depend on this property, that are mentioned previously on the same document.

As it was mentioned, this property only applies when the block code is inside an object of a transaction template (Transaction, Selection, Prompt, etc.). When this property has the value 'Once per matching attribute' the following properties will appear:

EventBlocksImg17
 

Is Nullable :

Specifies whether the attribute that will be associated to the block code has to be nullable, doesn't have to be nullable or there are no restrictions in that characteristic. 


Is Foreign Key:

Specifies whether the attribute that will be associated to the block code has to be foreign key, doesn't have to be foreign key or there are no restrictions in that characteristic. 


Is Primary Key:

Specifies whether the attribute that will be associated to the block code has to be primary key, doesn't have to be primary key or there are no restrictions in that characteristic. 


Is Inferred:

Specifies whether the attribute that will be associated to the block code has to be inferred, doesn't have to be inferred or there are no restrictions in that characteristic. 


Is Formula:

Specifies whether the attribute that will be associated to the block code has to be a formula, doesn't have to be a formula or there are no restrictions in that characteristic.


Is First Level:

Specifies whether the attribute that will be associated to the block code has to belong to the first level of the transaction, doesn't have to belong to the first level of the transaction or there are no restrictions in that characteristic.


Is Visible :

Specifies whether the attribute that will be associated to the block code has to be visible in the form, doesn't have to be visible in the form or there are no restrictions in that characteristic.


Regular Expression:

It is the regular expression that will be checked within every attribute of transaction, in order to define to which of them the block code will be added.
 

So, when the property 'Include' is 'Once per matching attribute', the code block will be added for each attribute that acomplishes this restrictions.
 

In the first example of the block code 'Show Messages', as you can visualize, the code mentions the variables &Messages and &Message:

EventBlocksImg02

This variables are not included in the Web Form so will not be defined in the Web Panels which are created based on this template. In order to define them automatically you have the Variables section:

EventBlocksImg18

Variables (Not included in Web form)

The purpose of this node is to define the variables that are used in some block codes, but they are not on the form (they are not inserted in instance's tree), so that WorkWithPlus defines it and you don't have to define them one by one for each object based on this template.

When you try to insert a Variable, it will open a window where you select from which attribute, domain, SDT, or bussiness component this variable will be based on.

By default it will assign the same name of the att/domain based on, but you can change it.

As you can visualize in the image, the variables &Message and &Messages are defined there, with its correspondent type

Message Definition:

EventBlocksImg19