Skip to content
Flexible record lookup in Business Central

Lookup any Record, from any Table

Daniel Gorski
Daniel Gorski 07. Juni 2023
2 Min. Lesezeit

Have you ever wondered if you could create more flexible lookups? Maybe you have a function where the user is required to select a record from a specific table, depending on the situation?

As an example, let’s create a copy function for sales document comments.

Page.RunModal(0,Rec) is providing a hidden "feature". The compiler does not allow you to pass something like a RecordRef into the function, but it does allow you to pass a variant. And the most interesting thing is that the Variant will contain the value of the last record selected, when “RunModal = Action:LookUp” evaluates to true.

So, for example, we can apply a filter to a RecordRef (or the actual Record) according to the document type and pass the filtered record into a Variant. If we don’t need any pre applied filters, we just open the RecordRef or pass an unfiltered Record into the Variant.

For simplicity, we choose the RecordRef approach here, since the enumeration ordinals of “Sales Comment Document Type” conveniently match those of the “Sales Document Type” for the unposted documents.

This function enables us to quickly write a multi table lookup, returning the Document No. of the chosen Document Type.

The full source code of “Copy Sales Comments” can be found in our GitHub Repository.

https://github.com/byndit/BeyondAL

how-to
development
business central
lookup
recordref
variant
sales comments
GoBD-konforme Archivierung mit Business Central und SharePoint ohne DMS

Architektur

Revisionssicher archivieren ohne DMS? Wie weit Business Central, SharePoint und Azure Blob Storage wirklich tragen

Warum „GoBD" oft vorschnell zum K.O.-Kriterium wird – und wie weit Business Central, SharePoint und Azure Blob Storage wirklich tragen.

Read More: Revisionssicher archivieren ohne DMS? Wie weit Business Central, SharePoint und Azure Blob Storage wirklich tragen
Read More: Revisionssicher archivieren ohne DMS? Wie weit Business Central, SharePoint und Azure Blob Storage wirklich tragen
Modulare ERP-Architektur für skalierbare Unternehmenssoftware

Architektur

Mehr als nur Warenwirtschaft - die Landtechnik Lösung

ERP-Systeme wurden jahrelang als Monolithen verkauft. Die eigentliche Stärke moderner Plattformen wie Business Central liegt jedoch in der Modularität - und gen

Read More: Mehr als nur Warenwirtschaft - die Landtechnik Lösung
Read More: Mehr als nur Warenwirtschaft - die Landtechnik Lösung