Any way to filter lookup in report?

EmerikEmerik Member Posts: 50
Hi Mibuso,
If I am making a report on a dataitem, let's say Purchase Header. When the user runs the report, he can set filters on the Purchase Headers, and make a lookup to the Purchase Header lookup table.
But is there a way, I can filter the records from properties or code, if e.g. I only want to let the user select Purchase Headers with Document Type=Credit Memo?

Thanks for any reply!

Comments

  • jspoppjspopp Member Posts: 54
    Hi Emerick, take a look at the DataItemTableView property for the Purchase Header DataItem. If you drill down to Table Filter, you should be able to accomplish what you looking for.
  • EmerikEmerik Member Posts: 50
    jspopp wrote:
    Hi Emerick, take a look at the DataItemTableView property for the Purchase Header DataItem. If you drill down to Table Filter, you should be able to accomplish what you looking for.

    Hi jspopp,
    Thanks for your reply. Unfortunately, it doesn't work. Even though I add a table filter, I am still able to select records, that do not respect the filter.

    I have also tried to add a filter by code. I have tried the following triggers, but nothing seems to work: OnInitReport, OnPreReport, OnPreDataItem

    BR Emerik
  • ChinmoyChinmoy Member Posts: 359
    As jspopp suggested, set the DateItemTableView filter as desired and on the OnPreDataItem trigger put this code:

    FILTERGROUP(4);

    This shud do the trick.

    Chn
  • EmerikEmerik Member Posts: 50
    Chinmoy wrote:
    As jspopp suggested, set the DateItemTableView filter as desired and on the OnPreDataItem trigger put this code:

    FILTERGROUP(4);

    This should do the trick.

    Chn

    Unfortunately not. It didn't work.
  • ChinmoyChinmoy Member Posts: 359
    Are there any other customized codes somewhere else, which may be resetting the dataitem? I ask this because it works for me, and see what C/SIDE ref guide has to say about filtergroup:

    "If, for example, a filter has been set on customer numbers 1000 to 2000 in group 4, the user can set a filter that delimits this selection further, but cannot widen it to include customer numbers outside the range 1000 to 2000."

    I think this is what you wanted.. right?

    Chn
  • KrasseKrasse Member Posts: 3
    I would make a Field on the RequestForm and add this code to the OnLookUp Property.

    <Control1100004000> - OnLookup(VAR Text : Text[1024];) : Boolean
    PurchHeader.FILTERGROUP(4);
    PurchHeader.SETRANGE("Document Type", PurchHeader."Document Type"::Credit);
    PurchHeader.FILTERGROUP(0);
    
    IF FORM.RUNMODAL(0,PurchHeader) = Action::LookUpOk THEN BEGIN
      Text := PurchHeader."No.";
      EXIT(TRUE);
    END;
    EXIT(FALSE);
    
    <Control1100004000> - OnDrillDown()
    

    You then can Copy the Filters into the DataItem (Purchase Header).

    Greetings from Austria
Sign In or Register to comment.