SETFILTER on two fileds with OR - problem

ponury20ponury20 Member Posts: 11
Hello everyone, I hope someone will be able to help me with my small problem.
I have a setup table for all user, where I can mark user as a Requestor and Approver. I also have a table with fields Approver and Requestor filled with proper ID of user. Table has its own card form.
I try to filter all records shown by my form using FILTERGROUP(2) and SETFILTER (or SETRANGE, does not make any difference) - depending on user is logged in and using the form. And for example when user opens the form and in setup table he is marked as Requestor - he can see only records with his ID in field Requestor. When he is marked as Approver - he can see only records with his ID in Approver field. But there is a problem - when user is marked as Requestor AND ALSO as a Approver, I do on my form :
SETFILTER("Approver", USERID);
SETFILTER("Requestor", USERID);
but this makes the user to see only records where he is an Approver AND ALSO a Requestor. I need to see records where he is an Approver OR Requestor.
How can I make some kind of OR in SETFILTER (SETRANGE) functions for two fields?
This problem is really annoying to me, sorry for my english.
Thx in advance.

Comments

  • vijay_gvijay_g Member Posts: 884
    Try it with IF condition(you can use OR AND with it) as it's not possible with SETFILTER.
    if ("Approver" = USERID) OR ("Requestor" = USERID) THEN
       REC.MARK(TRUE);
    
  • ponury20ponury20 Member Posts: 11
    I am not sure if this is a proper solution. I try to filter form in OnOpenForm trigger by setting filterts in filtergoup. Rec. MARK(true) does not set filters or anything like that, so user, when openning the form will see all records.
    I understand that by that I can mark actual record (or not mark it - depends on what I need to check), but how can I use it? Maybe there something that I am missing? Maybe I can somehow 'skip' a record when I check that it not should be seen by current user?
  • SogSog Member Posts: 1,023
    with the markedonly function you can filter marked records.
    There is no option to filter with or.
    So filter the records on approver = userid, then iterate over them and mark them. remove the filter of approver (or for a faster result altough small table I doubt it will be noticable set the filter of approver <> userid, set the filter on requestor, en mark those results.
    After that remove the filter again and set markedonly on that recordset.
    Only the marked records will be visible.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • kinekine Member Posts: 12,562
    Or, base the form on temporary table. Go through the real records filtered for first condition in first loop and for second in second loop. All found records fill into the temp table if not already there. Show the temp table... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • MGM08MGM08 Member Posts: 41
    if usersetup.approver then
    setfilter(approver,userid);

    if usersetup.Requestor then
    setfilter(Requestor,userid);

    then ur filtergroup
Sign In or Register to comment.