mibuso.com

Microsoft Business Solutions online community
It is currently Sat Sep 20, 2014 1:55 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Lookup filter in report
PostPosted: Thu Sep 02, 2010 4:50 pm 
Offline

Joined: Fri Oct 28, 2005 1:46 pm
Posts: 138
Location: London
Country: United Kingdom (uk)
Report.
NAV 2009 Classic.

I need to be able to filter the customer records when the user looks up the No. field from the dataitem Customer.

I have tried:

Report - OnInitReport()
Customer.FILTERGROUP(2);
Customer.SETRANGE("Rebate Customer Type", 2); //Customer."Rebate Customer Type"::Rebate);
Customer.FILTERGROUP(0);

The above is not working although suggested by someone on another forum.
The user should not be restricted elsewhere, just for this report.

The report has a filter anyway so there is nothing going to happen if the user selects the wrong record but I am hoping there is a way of pre-filtering the list?

](*,)

_________________
Experience is what you get when you hoped to get money


Top
 Profile E-mail WWW  
 
 Post subject: Re: Lookup filter in report
PostPosted: Thu Sep 02, 2010 5:17 pm 
Offline

Joined: Fri Oct 28, 2005 1:46 pm
Posts: 138
Location: London
Country: United Kingdom (uk)
OK, not perfect but I have added the No. field on the request Form:

<Control1000000000> - OnLookup(VAR Text : Text[1024];) : Boolean
Cust.FILTERGROUP(2);
Cust.SETRANGE("Rebate Customer Type", 2); //Customer."Rebate Customer Type"::Rebate);
Cust.FILTERGROUP(0);
IF FORM.RUNMODAL(0,Cust) = ACTION::LookupOK THEN
Customer."No." := Cust."No.";

That at least filters the records but is not what I was hoping for as I need to be able to select a range.

:-k ........

_________________
Experience is what you get when you hoped to get money


Top
 Profile E-mail WWW  
 
 Post subject: Re: Lookup filter in report
PostPosted: Thu Sep 02, 2010 8:24 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Fri Feb 03, 2006 10:15 pm
Posts: 2291
Location: Houston, TX
Country: United States (us)
Saw your post on DynamicsUser. This one is a bit more clear. Try adding this nice little function to the list form. I honestly can't remember if it was a base function on some of the forms in NAV 2009 SP1 or if I wrote it :lol: This one is from the Item List form, so you'll have to change it a little.

Code: Select all
CurrForm.SETSELECTIONFILTER(Item);
ItemCount := Item.COUNT;
IF ItemCount > 0 THEN BEGIN
  Item.FIND('-');
  WHILE ItemCount > 0 DO BEGIN
    ItemCount := ItemCount - 1;
    Item.MARKEDONLY(FALSE);
    FirstItem := Item."No.";
    LastItem := FirstItem;
    More := (ItemCount > 0);
    WHILE More DO
      IF Item.NEXT = 0 THEN
        More := FALSE
      ELSE
        IF NOT Item.MARK THEN
          More := FALSE
        ELSE BEGIN
          LastItem := Item."No.";
          ItemCount := ItemCount - 1;
          IF ItemCount = 0 THEN
            More := FALSE;
        END;
    IF SelectionFilter <> '' THEN
      SelectionFilter := SelectionFilter + '|';
    IF FirstItem = LastItem THEN
      SelectionFilter := SelectionFilter + FirstItem
    ELSE
      SelectionFilter := SelectionFilter + FirstItem + '..' + LastItem;
    IF ItemCount > 0 THEN BEGIN
      Item.MARKEDONLY(TRUE);
      Item.NEXT;
    END;
  END;
END;
EXIT(SelectionFilter);


You'll want to declare your form as a variable and use that method to set the filter (it returns a text variable).

SETFILTER("No.", CustomerListForm.GetSelectionFilter);

_________________
Matt Traxinger - ArcherPoint
Microsoft Dynamics NAV 2009 Programming Cookbook
Do you have an idea to improve NAV? Submit it at I Love NAV


Top
 Profile  
 
 Post subject: Re: Lookup filter in report
PostPosted: Fri Sep 03, 2010 8:16 am 
Offline

Joined: Mon Jul 28, 2008 2:37 pm
Posts: 674
Location: AT
Country: Austria (at)
Never mind...


Top
 Profile  
 
 Post subject: Re: Lookup filter in report
PostPosted: Wed Sep 08, 2010 5:16 pm 
Offline

Joined: Fri Nov 09, 2007 1:20 pm
Posts: 456
Location: Germany
Country: Germany (de)
As far as I know it is not possible to set any filters programmatically from within the report such that it is effective at the time the request form is shown.
There are two approaches you can take:
  1. Use the DataItemTableView property
  2. Use SETTABLEVIEW before you run the report. You may use the default filtergroup so the filter is visible in the request form, or you can use a different filtergroup on the rec you use as a parameter for SETTABLEVIEW to hide the filter from the user
In any of these cases the filter is effective on lookup and during the report.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: