K2BTrnContext variable

Introduction

Transactions may be called from different scenarios. Depending on those scenarios, the desired behavioiur of the transaction may be different. For example, it may be important to redirect the user to an specific Web Panel after the transaction is completed, or it may be necessary to pre-load some of the transaction's attribute values.

Using the parm rule may solve some of these scenarios, but that solution does not scale well when several parameters must be added.

That is the reason why the "K2BTrnContext" variable was created. This is a variable passed to the transaction via the Web Session that contains all the customizable parameters for that transaction. The variable is based on the K2BTrnContext SDT.

K2BTrnContext SDT

K2BTrnContextStructure
K2BTrnContext structure

The values for each of the attributes are defined as follows:

Name Value
TransactionName Should contain the name of the transaction that will be called using this TrnContext variable.
CallerUrl Should contain the url of the object that is calling the transaction.
EntityManagerName Name of the Entity Manager that is calling this transaction (if any). This is used when "Entity Manager" after trn navigation is used. See the K2BTrnNavigation SDT definition below for more information.
EntityManagerNextTaskCode Name of the task code that should be called after confirming the transaction. This is used when "Entity Manager" after trn navigation is used. See the K2BTrnNavigation SDT definition below for more information.
EntityManagerNextTaskMode Name of the mode that should be used to call the next task after confirming the transaction. This is used when "Entity Manager" after trn navigation is used. See the K2BTrnNavigation SDT definition below for more information.
ReturnMode Determines how the transaction will return to its caller after it is confirmed, when the After Trn Action is "Return To Caller".
AfterInsert Contains the definition for After Trn actions executed after an insert operation is completed. This field is based on the K2BTrnNavigation SDT (described later).
AfterUpdate Contains the definition for After Trn actions executed after an update operation is completed. This field is based on the K2BTrnNavigation SDT (described later).
AfterDelete Contains the definition for After Trn actions executed after an delete operation is completed. This field is based on the K2BTrnNavigation SDT (described later).
Attributes Collection of key value pairs used to pre-instantiate FK values.

K2BTrnNavigation SDT

K2BTrnContextStructure
K2BTrnContext structure

The values for each of the attributes are defined as follows:

Name Value
AfterTrn

Describes what to do after the transaction is confirmed. Possible values are:

  • Return To Caller: The transaction will redirect the user to the object that called it. This will be done as indicated in the ReturnMode fields in K2BTrnContextSDT.
  • Entity Manager: The transaction will redirect the user to the next task in the EntityManager, as described in the EntityManagerName, EntityManagerNextTaskCode, EntityManagerNextTaskMode fields in K2BTrnContextSDT.
  • Dynamic Link: The transaction will redirect the user to the object specified in the "ObjectToLink" field.
  • None: No actions will be taken after confirming the transaction.
ObjectToLink Contains a link to a GeneXus object that should be called after confirming the transaction. (If AfterTrn = "Dynamic Link").
Mode Contains the mode that will be passed as a parameter to the object specified in the ObjectToLink field.
ExtraParameter Contains extra parameters for the object specified in the ObjectToLink field.

Using K2BTrnContext

To use this variable, the developer must initialize it before calling the transaction. After initializing it, the developer must call the "K2BSetTrnContext" procedure, to save the variable in the Web Session.

FKManualInvokation
Manual Foreign Key Initialization