web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Get table records via table number?

(0) ShareShare
ReportReport
Posted on by 70

Is it possible with any methods in AL to fetch all of the records from a table using the table number? I'd like to be able to do this in an API call that way if I'm trying to access/set a property with a lookup I can make the query to fetch all records related to the lookup number.

I have the same question (0)
  • Suggested answer
    Akshay_Panchal Profile Picture
    402 on at

    Hi,

    Please check below reference link

    docs.microsoft.com/.../recordref-get-method

    Thanks

    Verify, If this answer helpful to you

  • Connor Hyde Profile Picture
    70 on at

    Hi Akshay,

    Thanks for the response.

    Maybe I'm not implementing the method correctly, but that doesn't seem to be fetching a record. Whenever I try making my procedure return any type besides "Text", the API call returns "Resource not found for the segment {Codeunit_Method}".

    I tried returning a text of RecRef.Field(num).Name + RecRef.Field(num).Value but most of the time that just returns a field name with empty value.

  • Mohamed Amine Mahmoudi Profile Picture
    26,801 Super User 2026 Season 1 on at

    hi you can use :

    var

       RecRef: RecordRef;

       MyFieldRef: FieldRef;

       RecID: RecordId;

    begin    

       RecRef.Open(TableNumber);  

       MyFieldRef := RecRef.Field(1);  

       MyFieldRef.Value := '30000';  

       if RecRef.Find('=') then begin  

         RecID := RecRef.RecordId;  

         RecRef.Get(RecID);  

       end;  

    end;

  • Connor Hyde Profile Picture
    70 on at

    Hi Mohamed,

    Thank you for responding. This does work for returning a specific record with field #1 value = '30000', but is it possible to return ALL records on the table?

  • Verified answer
    Akshay_Panchal Profile Picture
    402 on at

    Hii,

    see below, if you want to get all records from the given table id

    var

       RecRef: RecordRef;

       MyFieldRef: FieldRef;

       RecID: RecordId;

    begin    

       RecRef.Open(18);  

       if RecRef.Find('-') then repeat

         //your code here

       until RecRef.Next()=0;  

    end;

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,926 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,158 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 533 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans