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

Community site session details

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

How can I Learn - How to use Get method ,setrange(), setfilter(),and other basic methods in AL

(0) ShareShare
ReportReport
Posted on by 35

How can I Learn - How to use Get method ,setrange(),  setfilter(),and other basic methods in AL 

I am really excited to learn this language, so can please refer some methods to learn this language , microsoft learn is bit confusing for me so any other resources 

can you people suggest it will be a great help!!

Thanks in advance.

I have the same question (0)
  • Suggested answer
    Amit Profile Picture
    2,557 on at
    RE: How can I Learn - How to use Get method ,setrange(), setfilter(),and other basic methods in AL

    Hi,

    Refer the below link

    https://erpconsultors.com/use-of-setrange-and-setfilter-in-dynamics-365/

    For more learning visit www.erpconsultors.com

    Regards
    Amit Sharma
    www.erpconsultors.com
    Press Yes if Info is useful

  • Suggested answer
    DAnny3211 Profile Picture
    11,382 on at
    RE: How can I Learn - How to use Get method ,setrange(), setfilter(),and other basic methods in AL

    Hi

    the concept is very simple

    the setrange and setfilter applied to a table instance in AL return a set of data that you can cycle through... e.g. REPEAT UNTIL

    the get, on the other hand, is nothing more than a quick pointer using the primary key of the table to position you on the desired record. Be careful that when you use GET you are not returning a data set, so you cannot apply a loop otherwise your code will scroll through the table records from your selected record to the end

    www.youtube.com/watch

    DANIELE

  • Suggested answer
    YUN ZHU Profile Picture
    93,222 Super User 2025 Season 2 on at
    RE: How can I Learn - How to use Get method ,setrange(), setfilter(),and other basic methods in AL

    Hi, 

    Get method: retrieves one record based on values of the primary key fields.

    setrange(),  setfilter(): Assigns a filter to a field that you specify. Basically the same, but setfilter can take parameters.

    For example, 

    DimensionValue.SetFilter("Dimension Id", '<>%1', BlankGuid);

    Then I don't remember which expert's blog I downloaded the picture below, but it has always been useful. Hope that gives you some hints too.

    pastedimage1669594129231v1.png

    Thanks.

    ZHU

  • Suggested answer
    Steven Renders Profile Picture
    5,672 Moderator on at
    How can I Learn - How to use Get method ,setrange(), setfilter(),and other basic methods in AL
  • Community member Profile Picture
    4 on at
    How can I Learn - How to use Get method ,setrange(), setfilter(),and other basic methods in AL
    To use the GET method, SETRANGE(), SETFILTER(), and other basic methods in AL, you can follow these steps:
    Create a new codeunit or add code to an existing one where you want to use these methods.
    Declare variables to hold the data you want to retrieve or modify using these methods. For example:
    VAR
      Record: RecordName;
      Text: Text[50];
      Integer: Integer;

    Use the GET method to retrieve a record by its primary key or any other field. For example: 
    Record.GET(PrimaryKeyValue);
    Record.GET("Field Name", FieldValue);
     
    Use the SETRANGE() method to filter records based on specific criteria. For example:
    Record.SETRANGE("Field Name", FilterValue);
    Record.SETRANGE("Field Name", FilterValue1, FilterValue2);
     
    Use the SETFILTER() method to filter records based on complex criteria using operators like '=', '<>', '>', '<', '<=', '>=', etc. For example:
    Record.SETFILTER("Field Name", '[Operator]', FilterValue);
     
    Use other basic methods like FINDSET(), FINDFIRST(), FINDLAST(), NEXT(), etc., to navigate through the filtered records or perform operations on them. For example:
    IF Record.FINDSET THEN BEGIN
      // Handle the found records
      ...
    }
    Record.FINDFIRST;
    WHILE Record.NEXT DO BEGIN
      // Handle each record
      ...
    }
     
    Use additional methods like INSERT, MODIFY, DELETE, or MODIFYALL to modify the retrieved records as per your business logic. For example:
    Record.DELETE;
    Record.MODIFY;
    Record.MODIFYALL(FieldToUpdate, NewValue);
    These are some of the basic methods you can use in AL to work with records and data in Dynamics 365 Business Central. Modify them as per your specific requirements.
  • Community member Profile Picture
    2 on at
    How can I Learn - How to use Get method ,setrange(), setfilter(),and other basic methods in AL
    The use of Setter and Getter is necessary in controlling important properties that are often used and require exact values. For example, the age attribute stores a person's age. In reality, the age range is from 0 to 100, so we cannot let the program store a negative age value or more than 100. 
  • Suggested answer
    Dr Gomathi MVP, MCT Community lead, MLE Profile Picture
    389 Super User 2025 Season 2 on at
    How can I Learn - How to use Get method ,setrange(), setfilter(),and other basic methods in AL

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 2,828

#2
Sumit Singh Profile Picture

Sumit Singh 2,617

#3
YUN ZHU Profile Picture

YUN ZHU 1,861 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans