SETFILTER parameter problem

erik_kurniawanerik_kurniawan Member Posts: 7
Hi experts,

I have 15 parameter to use in Filtering some data. such as many problem this may not possible to use code SETFILTER(Data,'%1|%2...%15,value1,value2...value15) because theres only 12 maximum parameter. Is there any technique to handle this problem? thanks before...

Answers

  • BeliasBelias Member Posts: 2,998
    do not use parameters
    setfilter(myfield,format(myvariable) + '..' + format(myothervariable));
    
    and so on..
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • bluerockbluerock Member Posts: 32
    Divide it into 15 filters:

    "Sales Header".SETFILTER("Document Type", "Sales Header"."Document Type"::Order);.
    .
    .
    .
    15th filter
  • krikikriki Member, Moderator Posts: 9,110
    txtFilter := 'A|B|C|D'; // and this string you can make in different ways.

    A way:
    txtFilter := '';
    recSomeTable.RESET;
    recSomeTable.SETCURRENTKEY(...)
    recSomeTable.SETRANGE(...);
    IF recSomeTable.FINDSET THEN
      REPEAT
        txtFilter := txtFilter + '|' + recSomeTable."Some Field";
      UNTIL recSomeTable.NEXT = 0;
    txtFilter := COPYSTR(txtFilter,2);
    

    Now you have your field txtFilter with a filter in it. Use it like this:
    TheTable.SETFILTER("Some Field",txtFilter);
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • BeliasBelias Member Posts: 2,998
    bluerock wrote:
    Divide it into 15 filters:

    "Sales Header".SETFILTER("Document Type", "Sales Header"."Document Type"::Order);.
    .
    .
    .
    15th filter
    :? :? :? :? :?
    are you crazy?!?!only the last setfilter will be valid...each time you do a setfilter/setrange on a particular field, it overwrites previous filters on the same field (stating that you're working with the same record variable).

    EDIT: kriki just remembered me that there's a way: with the help of filtergroups.
    http://www.mibuso.com/forum/viewtopic.php?f=32&t=34863&p=169387&e=169387
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • krikikriki Member, Moderator Posts: 9,110
    The different filtergroups work like AND between them, so I don't think that in this case it is the correct way.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • BeliasBelias Member Posts: 2,998
    I was pointing out only that is actually possible to set filters on the same field without overwriting the previous one.
    The correct solution to the original problem of this thread is the one in the 2nd or 4th post (best is 4th, anyway)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • erik_kurniawanerik_kurniawan Member Posts: 7
    Dear all,

    sorry i haven't explain before.
    here the full story...

    Navision have Responsibility Center field.

    in this case i want to make multiple resp. center to Filter Customer.
    The step is ;

    1. I have assigned customer to one resp. center before.
    2. I have made one tabel contain role information.
    Field ; username, resp. center

    The record is like ;
    - username A, resp. center A
    - username A, resp. Center B
    - username A, resp. center C
    - username A, resp. center D
    - username A, resp. center E
    - username A, resp. center F
    - username A, resp. center G
    - username A, resp. center H
    - username A, resp. center I
    - username A, resp. center j
    - username A, resp. center K
    - username A, resp. center L
    - username A, resp. center M
    - username A, resp. center N

    3. When user want to open customer card form and also customer list form, it will check to role table about username role.
    so the result is 'username A only can see customer that have resp. center A,B,C,D,E,F,G,H,I,J,K,L,M,N'.

    Its not possible to use code SETFILTER because maximum parameter is 12.

    My question is how to make the filter is possible?

    Thanks all...
    Regards,

    Erik
  • SogSog Member Posts: 1,023
    Look at the post Kriki made
    this will make a string with all the responsibility centers for that user.
    Let's say username A opens the customer card
    then with kriki's method you get a filter like:
    setfilter("resp. center","A|B|C|D|E|F|G|H|I|J|K|L|M|N")
    so instead of a filter with 15 parameters you get 1 parameter with all the 15 responsibility centers in and the | sign
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • DenSterDenSter Member Posts: 8,305
    Be aware that a filterstring can only be 250 characters. So if you have 15 customers with numbers that are 20 characters, you are going to run into an error. I'd consider an alternative solution, perhaps one with a temporary record variable.
  • erik_kurniawanerik_kurniawan Member Posts: 7
    Ok, I will try kriki's method. I hope it can solve my problem [-o< ...

    thanks all.

    Regards,
    Erik
  • pawanppawanp Member Posts: 90
    Be aware that a filterstring can only be 250 characters. So if you have 15 customers with numbers that are 20 characters, you are going to run into an error. I'd consider an alternative solution, perhaps one with a temporary record variable.
    How to implement and alternative solution using a record variable..
    As my key is exceeding maximum character length..
    Please someone help on this context.. Its urgent. ](*,)
  • mabl4367mabl4367 Member Posts: 143
    1. Create a temp record variable. (Just set its "Temporary" property to "Yes".

    2. Filter the customers once for each responsibility center that the user belongs to and copy the records you get to the temporary table.
  • AndwianAndwian Member Posts: 627
    3. When user want to open customer card form and also customer list form, it will check to role table about username role.
    so the result is 'username A only can see customer that have resp. center A,B,C,D,E,F,G,H,I,J,K,L,M,N'
    I think it is by design. No need to do modification.
    Regards,
    Andwian
Sign In or Register to comment.