Official Content

Ends the execution and returns to the caller program.

Syntax

Return

Scope

Objects: Procedure, Transaction, Web Panel, Panel, WorkWith
Generators: .NET, .NET Framework, Java AppleAndroid

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 consider that the database updates are not made when the assignment is performed, but 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 in the database yet (because the 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

See Also

HowTo: Return from a Panel to the caller Panel in Native Mobile Apps

Last update: March 2025 | © GeneXus. All rights reserved. GeneXus Powered by Globant