Call methodOfficial Content

Allows to call a GeneXus object (either with transfer of parameters or not) such as a Web Panel or a Procedure, etc., from another object (which is the caller). 

Syntax

ObjectName.Call([parm1, .... , parN])

Where:

ObjectName
      Is the name of the object we want to call.

par1, …, parN
      Are optional parameters that can be sent to the called object with some purpose (and they must be received in the called object by declaring them with the Parm rule).

The Call method can be written in different sections of the caller object, depending on whether the caller is a Transaction, a Web Panel, a Procedure, etc. (if the caller is a Procedure, the Call method must be included in some line of it's source; if the caller object is a Transaction, the call can be included in it's rules section as well as inside an event, depending on the requirement, etc.).

Important: The syntax of the Call method allows us to omit the dot and the Call, and the invokation will be exactly the same, because GeneXus has the intelligence to detect that we are calling an object.

Examples

1) Let's suppose we have a Web Panel in our Knowledge Base, that only has a button included in it's form. When the user press the button, the event associated to the button is executed and our objective is to call a Procedure that print all the customers. So, we define the following code inside the event associated to the button, in order to achieve our objective:

Event 'Print all customers'
    PrintAllCustomers.call()
EndEvent

The following code behaves exactly like the above:

Event 'Print all customers'
    PrintAllCustomers()    //the dot and the call were omited
EndEvent

In both examples, the Procedure named PrintAllCustomers is called without parameters (so, no Parm rule is needed to be defined in the Procedure).


2) Now let's suppose the Web Panel has a Dynamic Combo Box in it's form, that shows all the countries stored in the database. And the button is also present in the form. The user will select a country and after that, he will press the button. Our objective in this case, is to call a Procedure that print all the customers who belong to the country selected by the user.

ImageForCallMethodExample

When the user select a country, the CountryId attribute value will be assigned to the &CountryId variable associated to the Dynamic Combo Box. After that, when the user press the button, the event associated to the button will be executed.

So, inside the event associated to the button we have to define the invokation to the Procedure. In this case, we have to send to the Procedure the &CountryId variable as a parameter. The Procedure will receive the parameter (we have to declare the parameter in the Procedure with the Parm rule); finally, we will use the received value in the Procedure, in order to filter the customers that belong to that country.

The following code inside the event associated to the button, is calling the Procedure named PrintCustomers, and the &CountryId variable is sent to it as a parameter:

Event 'Print customers'
    PrintCustomers(&CountryId)    
EndEvent

The Procedure must have defined the following rule:

parm(&CountryId);

...and the variable is used in the Procedure source in order to filter the customers that belong to that country, like the following code shows:

ImageForCallMethodExample2

 

Notes for Smart Devices objects

For Smart Devices objects, the Call method must be written in the Smart Device Events.

 

See also

Udp method

 

Videos

Start Video Communication between objects