Official Content

You can indicate that certain rule(s) and/or event(s) defined in a Transaction object are only executed when the object is run for specific user interfaces (Windows/GUI, Web/HTML, Text) and/or when the data is handled through Business Components in backend processes.


There are two possible syntaxes:

1) Individual: 

rule | event

2) By Block:

rule | event
rule | event


[ContextIdentifier1] [ContextIdentifier2] [ContextIdentifierN]
     Indicate the context(s) for which the rule(s) / event(s) must be executed. The possible values are:

  • [web]: The rule(s) / event(s) that follow will be triggered when the Transaction Web Layout (HTML) is executed.
  • [bc]: The rule(s) / event(s) that follow will be triggered when the Transaction is executed as Business Component in backend processes.
  • [win]: The rule(s) / event(s) that follow will apply to Windows / GUI forms.
  • [text]: The rule(s) / event(s) that follow will apply to char based user interfaces.
  • [business]: This is the default value. It is like not indicating any ContextIdentifier or indicating all of them. 

     Rule or list of Transaction rules.

     Event or list of Transactions events.


Objects: Transaction


Some validations or actions may only make sense when the end user is interacting through the Transaction web interface, and not when the data is handled through Business Components or vice versa. So, this feature allows indicating in which contexts you want to execute certain rules and/or events.

The ability to define rules/events that only apply in certain contexts allows you to create business logic adapted to the specific needs of each type of interaction with the system. 

This is especially relevant in scenarios where different layers of interaction with the end users are handled or when finer control over the business logic is required depending on the origin of the operation (for example, web vs. backend).

In summary, the use of ContextIdentifiers allows to:

  • Specify the execution context: Clearly defines the scope in which a rule/event should be applied, improving code organization and clarity.
  • Customize the business logic: Adapt the behavior of the applications according to the execution environment, offering a richer and more accurate user experience.
  • Optimize performance: By avoiding the execution of unnecessary rules/events in certain contexts, the application performance can be improved.
  • Improve maintainability: Facilitates code understanding and maintenance by providing a clear mechanism to control where and how business rules are applied.


Sample #1: Individual definitions

Rules Tab of Customer Transaction

Noaccept(CustomerId) If Insert On AfterValidate;
CustomerAddress.SetNull() if CustomerAddress.IsEmpty()

Events Tab of Customer Transaction

Event After Trn

The NoAccept rule will only be applied in Windows or GUI environments, while the Start event is valid in Win and Web environments.

Sample #2

The next example shows the use of the Block syntax.

Parm(&CustomerId, &Mode);
CustomerId = &CustomerId If Update Or Delete;
Event After Trn       

Event ‘User’ 8
       //do something


Last update: April 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant