Passing Filter Criteria to proc

markclemarkcle Member Posts: 65
Hi All

New to Nav and AL code and working on first extensions. It's all working, but now I'm factorizing my code

I have a case statement that repeats this code and want to factorize it
                               SalesLine.SETRANGE("Document Type", rec."Document Type");
                               SalesLine.SETRANGE("Document No.", rec."No.");
                               SalesLine.SETRANGE(Type, SalesLine.Type::Item);
                               SalesLine.SetFilter("No.", 'FJOB | FCOM | FRES | FLIFT');
                               DeleteAll(TRUE);
  

I presume I could just pass Doc Type, Doc No, Line Type and the String for the Setfilter as params, so it's more general purpose (the calling proc can supply any list of items)

I've read about Setfilter, GetFilter and FilterGroups and wondering if I can somehow pass the entire "filter" as a single object instead of 4 params

What would be the best way to factorize this?

Thanks

Mark

Best Answer

Answers

  • JuhlJuhl Member Posts: 724
    Pass the Record
    Follow me on my blog juhl.blog
  • markclemarkcle Member Posts: 65
    Thanks for reply, but that leaves same duplicate code to apply all the filters and there will often be more than one record (hence the DeleteAll
  • TallyHoTallyHo Member Posts: 417
    Pass the record variable as VAR(!). That is different from just passing a line of fields in a table.
    It contains the current record, but you do not have to 'find' or 'get' the record first.
    You can use it to pass filters or anything else applied to it before it entered the function.
  • markclemarkcle Member Posts: 65
    Thanks for reply, but I need to operate on multiple records, so unless I can pass a filterset or something like a recordset (ADO), I don't see how this would work (or am i missing something)
  • markclemarkcle Member Posts: 65
    Thanks. That's what I was hoping. Will give it a shot
Sign In or Register to comment.