Options

Applying USERID filter on a form

liizzliizz Member Posts: 125
Hi all,

I have a form on which I want to apply filters based on the current system userid.

My codes is as follows:

Form - OnOpenForm()
SETRANGE("User ID",USERID);

Sometimes it gives the entries of this particular login but sometimes it shows all entries made by all users.

When it shows all the entries, I close the NAV application and restart my activity and then it is ok.

Please help where am wrong.

Thanks
Liizz

Comments

  • Options
    ara3nara3n Member Posts: 9,256
    I think somebody hits the ShowAll button which removes all the filters.

    You need to use

    FILTERGROUP(6);
    SETRANGE("User ID",USERID);
    FILTERGROUP(0);
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    liizzliizz Member Posts: 125
    Hi,

    I have two forms with the same source table. One form shows the User ID and the other shows the Approver ID.

    But, still when I use:

    FILTERGROUP(6);
    SETRANGE("User ID",USERID);
    FILTERGROUP(0);

    It prevents me from creating a new entry and I have to restart NAV application on the first form. I think the problem comes with the filters and it is not cleared. The source table is also blank.

    I have read this thread: http://www.mibuso.com/howtoinfo.asp?FileID=22

    Some advice: Only start using filtergroups from 10 and up. Filtergroups 0 to 6 are reserved (see the C/SIDE reference guide for more info), but I would keep some extra filtergroups free for the future (until some versions ago, filtergroup 6 was NOT reserved).

    Can I use this instead:
    1st form:
    IF UserSetup.GET(USERID) THEN BEGIN
    FILTERGROUP(10);
    SETRANGE("User ID",UserSetup."User ID");
    FILTERGROUP(0);
    END;

    2nd form:
    FILTERGROUP(10);
    SETRANGE(Approver,USERID);
    SETFILTER(Status,'%1',Status::Released);
    FILTERGROUP(0);

    Is it a best way to fix this issue out??

    Please advise me and help me sort it out.


    Thanls
    Liizz
  • Options
    TonyHTonyH Member Posts: 223
    Whats the source table you are using?

    t
  • Options
    ara3nara3n Member Posts: 9,256
    I don't see anything wrong with your code.

    You'll need to test it and make sure it works if users are entering records. If they are then you'll need to populate the user id automatically.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    liizzliizz Member Posts: 125
    If they are then you'll need to populate the user id automatically.

    I didnt get your point here.

    Its a customized table.

    Thanks

    Liizz
  • Options
    ara3nara3n Member Posts: 9,256
    If users are inserting new records on these forms, then on insert trigger in the table you need to add the code
    "user id" :=  USERID;
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.