Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Filtering a page with repeater - Sales Order List

(0) ShareShare
ReportReport
Posted on by 5,126

We have a sales order list which was customized so there's an additional field in the Sales Order List page called pstatus.  This pstatus is a global function in the page's source table which is sales header.  The pstatus function performs some calculation and then returns string values such as 'open', 'closed' or 'on hold'.  This pstatus is defined as a field in the Sales Order List where by source expression is the pstatus global function.  Needless to say, it worked like a charm so each sales order will have a pstatus of 'open' or 'closed', etc.  The problem I am running into is it's not part of the filter fields....most likely because it's a function and not a column field from Sales Header.  How can I filter the Sales Order LIst so users can select 'open' only pstatus?  IN the Filter ddlist, this pstatus column is not included.  I was thinking to add On action code unit?  Any sample code as to how to show a ddlist in the Action Tab or a group of radio buttons and then be able to filter the source of the sales order list so only records with pstatus='open' can show?

*This post is locked for comments

  • Verified answer
    Jens Glathe Profile Picture
    Jens Glathe 6,092 on at
    RE: Filtering a page with repeater - Sales Order List

    Hi mbr,

    this could be problematic. :) As I said, filtering on a value that is not in a normal field is not easy. What you need to achieve this is:


    1. A means to calculate the value. The pstatus function does this already. Only the returnvalue should be option, not text (you'll see soon why).

    2. A useful filtering facility to select the states you want to show in your list page. Therefore the flowfilter field with the same option values. This gives you the whole filtering syntax NAV can do, settable via UI or C/AL, gettable via C/AL.

    3. A means to dynamically find/fetch the required record while applying the desired status filter and emulating the page behaviour. This is the hard part. Therefore I gave the link to an example on how to implement this. :)

    with best regards

    Jens

  • mbr Profile Picture
    mbr 5,126 on at
    RE: Filtering a page with repeater - Sales Order List

    ok. 'will give it a try. let me see if I can figure this out.  I can create the field called order status as option but the value doesn't get evaluated until a global function is called from Sales Order List.  'will see if I can just populate the value on getnextrecord of Sales Order List assuming this will not suffer degradation of performance.  Or I can look into the class=flowfilter from Sales Header table and see what that is about. thank you much.

  • Suggested answer
    Jens Glathe Profile Picture
    Jens Glathe 6,092 on at
    RE: Filtering a page with repeater - Sales Order List

    Hi mbr,

    well, getfilter only works on fields (and field references). My proposal was to create a field (named "Order Status" for example) of class "FlowFilter" and type "Option", with your texts as OptionValues. You can operate with getfilter on a flowfilter field... and you can set a filter as the user (Ctrl+Shift+F3 Limit Totals - yeah I know, usability is fscked, but it wasn't me), or from your actions or page triggers with setrange/setfilter. This is only a place to store the current filter on the page for this option... and very handy :)

    with best regards

    Jens

  • mbr Profile Picture
    mbr 5,126 on at
    RE: Filtering a page with repeater - Sales Order List

    Hi jens....can you elaborate the usage of filter field and getfilter? I tried getfilter but itis expecting a field?

  • mbr Profile Picture
    mbr 5,126 on at
    RE: Filtering a page with repeater - Sales Order List

    it may be not that easy as there are values already in the table.  THis function is called from a page with repeater control.  below is the global function defined in the Source Table:

    // Additional code required in Attain

    CALCFIELDS("Total Qty. To Ship (base)","Total Qty. Packed (base)");

    TotalQtyToShipBase := "Total Qty. To Ship (base)";

    IF TotalQtyToShipBase = 0 THEN BEGIN

     CALCFIELDS(

       "E-Ship Whse. Outst. Qty (Base)","E-Ship Whse. Ship. Qty (Base)",

       "E-Ship Invt. Outst. Qty (Base)");

     TotalQtyToShipBase :=

     "E-Ship Whse. Outst. Qty (Base)" + "E-Ship Whse. Ship. Qty (Base)" +

     "E-Ship Invt. Outst. Qty (Base)";

    END;

    CASE TRUE OF

     TotalQtyToShipBase = 0:

       EXIT(Text14000707);

     "Total Qty. Packed (base)" = 0:

       EXIT(Text14000708);

     TotalQtyToShipBase = "Total Qty. Packed (base)":

       EXIT(Text14000709);

     TotalQtyToShipBase < "Total Qty. Packed (base)":

       EXIT(Text14000710);

     ELSE

       EXIT(Text14000711);

    END;

  • mbr Profile Picture
    mbr 5,126 on at
    RE: Filtering a page with repeater - Sales Order List

    First of, thanks soooo very much for your generous transfer of knowledge.  I am very humbled and am truly appreciating the MS Partner Nav forum.  YOu have saved me hours of research! :)

    Anyway, it's good to know that my assumption is right whereby Nav's limitation on built in filters is in fact true regarding filtering only Fields from table as opposed to functions albeit called from field control in a Page.

    I tend to just opt with Action whereby I can call the GetFilter function and pass the parameter value given the button pressed by users.  Only coz it's easier as I don't have to mess with table design.  haha! So I will try your suggestion on Action and using GetFilter function.  wish me luck! I am so excited to try this!  Thank you.

  • Suggested answer
    Jens Glathe Profile Picture
    Jens Glathe 6,092 on at
    RE: Filtering a page with repeater - Sales Order List

    Hi mbr,


    this is a "built-in" limitation of NAV. You can do quite a lot in the C/AL triggers, but you can't filter on a variable. This must always be a field. In pages, it can be a normal field and also a flowfield. If it is possible to get the pstatus calculation into a flowfield (calling the function in the calcformula property is not allowed), you can solve this. The other way to solve this is way more complicated. You would have to modify the OnFindRecord() and OnNextRecord() triggers, and it isn't easy to achieve the desired "normal" behaviour due to clipping and different jump lengths. I have posted an example solution (still in use without change, also valid for pages AFAIK) here: http://dynamicsuser.net/forums/p/12307/35218.aspx#35218

    As for the filter control, you need to create actions for every option you need, or (far better) define a field in your table of type flowfilter. It doesn't matter that it's not used in a flowfield, but you can fetch the filter value in C/AL with getfilter() and copyfilter().

    with best regards

    Jens

  • Suggested answer
    keoma Profile Picture
    keoma 32,675 on at
    RE: Filtering a page with repeater - Sales Order List

    hi,

    replace in the sales header table the type of the pstatus field by an option field with values: open, closed

    change the code, so that this option field gets the right value per record. depends on the calculation formula select an onvalidate trigger to set the pstatus value.

    after that you are able to use that field for filtering.

    best regards

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans