community postAL Developmentcommunity - not Microsoftreviewed - checked by Opus

Dynamics 365 Business Central: How to use Page.SetSelectionFilter Method in temporary records

Page.SetSelectionFilter marks user-selected records but doesn't work directly with temporary records without additional setup. The post demonstrates two approaches: manually transferring data from source records to temporary records, or using Record.Copy with the ShareTable parameter set to true when both records are temporary.

post Dynamics 365 Lab

Yun Zhu · 2025-06-02 · 637 words · about 3 min

"Page.SetSelectionFilter(var Record) is a very commonly used method, which can get the value currently selected by the user."

Key points

  • Page.SetSelectionFilter notes user selections and filters to marked records only, but temporary records need data assigned beforehand
  • For normal source tables, retrieve data using FindSet and TransferFields to populate temporary records before applying SetSelectionFilter
  • For pages with temporary source tables, use Record.Copy with ShareTable set to true to reference the same table and apply SetSelectionFilter
  • The ShareTable parameter in Record.Copy can only be true when both records are temporary

Quotes

  • “Page.SetSelectionFilter(var Record) is a very commonly used method, which can get the value currently selected by the user.” (Establishes the core purpose of the method that developers need to understand)
  • “If the variable is temporary, the value will not be obtained. Because we did not assign values to this temporary table in advance.” (Identifies the key problem that developers encounter when working with temporary records)
  • “If FromRecord and Record are both temporary and ShareTable is true, then the COPY method causes Record to reference the same table as FromRecord.” (Explains the critical mechanism for handling temporary records with SetSelectionFilter)

AL objects mentioned

As named in the post. A name that matches one object page by exact type and name links to it; the others stay as named.

No source states these links: they share an object, a model read them, or a person found the same subject.

Heads up

  • gotcha: “If the variable is temporary, the value will not be obtained.”
  • warning: “Note that if the original table is not a temporary table, [Optional] ShareTable = true cannot be used.”

Context

  • Features: Page.SetSelectionFilter method, Record.Copy method, Temporary records, Record selection, Filtering marked records, TransferFields

Source: Dynamics 365 Lab - Yun Zhu, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.