Last week, the preview environment for Dynamics 365 Business Central 2021 release wave 1 (BC18) is available. Learn more: https://yzhums.com/10601/.
I will continue to test and share some new features that I hope will help.
Return record link instead of name when using lookups: the description is not very clear…
A common application scenario when typing in information is to allow a user to pick an entity based on find-as-you-type. This means entering part of the number, name, or description, getting a short list of possible matches, and then making a selection.
Until now, only the full value of the matched field would be returned, requiring the application to find the entity to link to by matching it with the value. If this was not a unique name, it could lead to the wrong entity being selected.
Now, instead of returning only the matched value, it will be possible to get information on the actual, selected record in the trigger, to ensure unique references.
When the user selects entries in lookup triggers, it will be possible in AL to retrieve the record link of the chosen entry, instead of just the name.
In short, Microsoft has added a new page field trigger (OnAfterLookup trigger) in BC18.
And this can be also used in Page extension. (OnAfterAfterLookup trigger)
Unfortunately, there is no MS document available at the time (2021/03/17), and it is not yet used in the standard code.
After my initial testing, I found it does not work after the Onlookup trigger, although its name is OnAfterLookup trigger. Whether I set the Onlookup trigger in Page or Table, the result is the same.
For example: I cannot see the msessage I specified.
But, I noticed that it works after TableRelation.
OK, let’s see some clearer examples.
OnAfterLookup trigger in Page.
OnAfterAfterLookup trigger in Page extension.
But if I choose Select from full list, the trigger is not worked. If the page jumps to another page, the OnAfterLookup trigger will not be executed. So, this is probably why it doesn’t work after the Onlookup trigger. So far I’m still a bit confused about how to use this trigger, I’ll test it in detail when Microsoft updates Docs later. Hope this will help.
MS Document has been updated.
OnAfterLookup Trigger: Runs after a record in a lookup has been selected and the lookup is closed. The trigger applies to page fields that have a
TableRelation defined, looking up values in another table.
Remark: 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.
Information from Dynamics 365 Business Central Launch Event 2021 release wave 1
Hope this will help.
Thanks for reading.