usage of Exit after filtering in AL

samantha73samantha73 Member Posts: 96
Hi
I have written a query to filter by setrange/setfilter and then findfirst to get the filtered records. If I don't use "Exit" then the query doesnt work so trying to understand why. Is using Exit best practice
example
first works and the second doesn't work
GenJournalLine2.Reset();
        GenJournalLine2.SetRange("Journal Template Name", GenJournalLine."Journal Template Name");
        GenJournalLine2.SetRange("Shortcut Dimension 2 Code", '');
        if GenJournalLine2.FindFirst() then
            if GenJournalLine2."Journal Template Name" = 'GENERAL' then
                exit else
                    error('');


        GenJournalLine2.Reset();
        GenJournalLine2.SetRange("Journal Template Name", GenJournalLine."Journal Template Name");
GenJournalLine2.SetFilter("Journal Template Name", '<>%1', 'GENERAL');
        GenJournalLine2.SetRange("Shortcut Dimension 2 Code", '');
        if GenJournalLine2.FindFirst() then
                    error('');[img]https://us.v-cdn.net/5022383/uploads/editor/ja/ab9p7k6ud0um.png[/img]

Answers

Sign In or Register to comment.