# OnAfterLookup (Page Field) trigger
> Version: _Available or changed with runtime version 7.0._
Runs after a lookup is activated passing the selected record as a RecordRef.
## Syntax
```al
trigger OnAfterLookup(Selected: RecordRef)
begin
    ...
end;
```
### Parameters
Selected
Type: ../../methods-auto/recordref/recordref-data-type
The selected record.
## Remarks
This trigger is introduced with runtime 7.0 of AL to address issues that arise when in Business Central, for example, more items have the same Description. With former solutions, the lookup mechanism would find the selected record based on the filtering in the lookup dialog. This made it impossible to predict which record the user had selected.
> NOTE
> If you have defined an devenv-onlookup-pagefield-trigger, the devenv-onafterlookup-pagefield-trigger will not be fired.
## Example
The following is a simplified example of how the OnAfterLookup trigger can be used. The No. and Description fields point to fields in the Item table and should be updated at the same time, even if only one of the fields is available in a dropdown; the corresponding field must also be set. No. is the primary key and unique, but there could be more records in the Item table with the same Description. The OnAfterLookup trigger looks up the chosen record and returns it in a RecordRef.
```al

table 37 "Sales Line"
{
    // Skipped

    fields
    {
        // Skipped

        field(6; "No."; Code[20])
        {
            TableRelation = Item;
        }
        field(11; Description; Text[100])
        {
            TableRelation = Item.Description;
            ValidateTableRelation = false;
        }

        // Skipped
    }
}

page 46 "Sales Order Subform"
{
    SourceTable = "Sales Line";

    layout
    {
        area(content)
        {
            repeater(Control1)
            {
                // Skipped

                field("No."; "No.")
                {
                    trigger OnAfterLookup(Selected: RecordRef)
                    var
                        Item: record Item;
                    begin
                        Selected.SetTable(Item);
                        Validate(Description, Item.Description);
                    end;
                }
                field(Description; Description)
                {

                    trigger OnAfterLookup(Selected: RecordRef)
                    var
                        Item: record Item;
                    begin
                        Selected.SetTable(Item);
                        Validate("No.", Item."No.");
                    end;
                }
                // Skipped
            }
        }
    }
}
```
## Related information
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/triggers-auto/pagefield/devenv-onafterlookup-pagefield-trigger, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/triggers-auto/pagefield/devenv-onafterlookup-pagefield-trigger/
