how to make a filtergroup

haritza10haritza10 Member Posts: 28
edited 2004-05-02 in Navision Attain
Hello everybody,

nobody know how to make a filtergroup withe a setrange but making or in the setrange?

example:

filtergroup(2);
setrange(..); //i have to do a setrange with 3 fields but no making AND, i have to making OR. i have to look if in field1 or field2 or field3.

filtergroup(0);

Thanks.

Comments

  • kinekine Member Posts: 12,562
    If you search this forum, you can see that OR between more fields filter you cannot use through setrange or setfilter but with more loops... (first fikter for first column, than for second etc.)

    :wink:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • haritza10haritza10 Member Posts: 28
    i know that it is impossible to make a setrange through OR but another way to make that i need?

    Thanks
  • Timo_LässerTimo_Lässer Member Posts: 481
    kine wrote:
    If you search this forum, [...]
    Use the Search, and you will find this topic:
    http://www.mibuso.com/forum/viewtopic.php?p=8399#8399
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • haritza10haritza10 Member Posts: 28
    I know this post, but i need this one making a filtergroup, so the end-users can't clear filters the records i make it.

    Thanks
  • Torben_R.Torben_R. Member Posts: 99
    I had a simular problem once. My customer wanted to filter the payroll data according to a rules entered into a separate table.

    The managers are allowed to accept time stamps for emplyees in certain department but not for all (i.e. themself).

    I managed to solve it like this (from the Employee card):
    FILTERGROUP(2);
    SetRights.SetRights(EmplFilter,DimFilter);
    SETFILTER("No.",EmplFilter);
    SETFILTER("Global Dimension 1 Code",DimFilter);
    FILTERGROUP(0);
    

    The function SetRights
    IF NOT Manager.GET(USERID) THEN
      ERROR(Text001);
    
    ManagerRights.SETRANGE("Manager No.",USERID);
    IF ManagerRights.FIND('-') THEN BEGIN
      IF ManagerRights."Accept all Employees" THEN BEGIN
        CLEAR(EmployeeFilter);
        CLEAR(DimensionFilter);
      END ELSE BEGIN
        IF (ManagerRights."Permission to Accept") AND (ManagerRights."Global Dimension 1 Code" = '') THEN BEGIN
          ManagerRights.SETRANGE("Permission to Accept",TRUE);
          ManagerRights.SETFILTER("Employee No.",'<>%1','');
          IF ManagerRights.FIND('-') THEN
            REPEAT
              IF EmployeeFilter <> '' THEN
                EmployeeFilter := EmployeeFilter + '|' + ManagerRights."Employee No."
              ELSE
                EmployeeFilter := ManagerRights."Employee No.";
            UNTIL ManagerRights.NEXT = 0;
          Found := TRUE;
        END ELSE BEGIN
          IF NOT Found THEN
            ManagerRights.SETRANGE("Permission to Accept",TRUE);
          ManagerRights.SETFILTER("Global Dimension 1 Code",'<>%1','');
          IF ManagerRights.FIND('-') THEN
            REPEAT
              IF DimensionFilter <> '' THEN
                DimensionFilter := DimensionFilter + '|' + ManagerRights."Global Dimension 1 Code"
              ELSE
                DimensionFilter := ManagerRights."Global Dimension 1 Code";
            UNTIL ManagerRights.NEXT = 0;
          ManagerRights.SETRANGE("Global Dimension 1 Code");
          ManagerRights.SETRANGE("Permission to Accept");
          ManagerRights.SETRANGE("Not permission to accept empl.",TRUE);
          ManagerRights.SETFILTER("Employee No.",'<>%1','');
          IF ManagerRights.FIND('-') THEN
            REPEAT
              IF EmployeeFilter <> '' THEN
                EmployeeFilter := EmployeeFilter + '&<>' + ManagerRights."Employee No."
              ELSE
                EmployeeFilter := '<>' + ManagerRights."Employee No.";
            UNTIL ManagerRights.NEXT = 0;
        END;
      END;
    END ELSE
      ERROR(Text001);
    

    Hopefully you can get some ideas from this.

    Regards
    Torben
  • nelsonnelson Member Posts: 107
    It is not possible to use Filter Groups and the Marked Only filtering simultaneously. It won't work, sorry.
    Nelson Alberto
  • RobertMoRobertMo Member Posts: 484
    Try to simulate marked only with additional field "Special Filter". instead of setting marks you can modify this field setting it's value to userid.
    at the end you just use:
    setfilter("Special Filter",USERID);

    you should also consider multiuser environment. (concatenating "Special Filter" and filtering as *USERID*)

    If possible you should use tmp rec and insert records you find into tmp rec. It will be faster and won't itnerfere with other users.
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Sign In or Register to comment.