Official Content

Ends the execution and returns to the caller program.

Syntax

Return

Scope

Objects: Procedure, Transaction, Web Panel, Panel for Smart Devices, Work With for Smart Devices
Generators: .NET, .NET Framework, Java Apple Android

Description

This command forces the running program to stop and return to the caller.

When the Return command is used within a For Each command, you must take into account that the database updates are performed immediately before the Endfor.

Consider the generic code given below:

For each
    att = value
    If <condition_is_true>
        Return    //consider that if you define this, att is not updated in the database yet
    Endif
EndFor

When the condition is satisfied and the Return command is executed, the attribute is not modified at that moment in the database because the actual database update is performed just before the Endfor.

Below is a particular example to solve this scenario.

Consider the following Transaction object

Supplier
{
    SupplierId*
    SupplierName
    SupplierPhone
    SupplierEmail
    SupplierReviewed
}

And the following Procedure object:

CheckSupplier Procedure
Rule: Parm(in:&SupplierId, out:&Flag);

Source:

&Flag = 0
For each Supplier
    where SupplierId = &SupplierId
          SupplierReviewed = 'Y'
          &Flag = 1       
EndFor
If &Flag = 1
    Return
EndIf
Note: This command is the replacement of the Return() method in SDActions external object.


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