Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Filter Record

Posted on by 3,027

Hi

  I have Main Form & Sub Form . Main Form Source Table is Location & Sub Form is Sale Line Table.  I have below code to filter record according to User Id Location . It should display only 1 record according to User Location . User should not be able to select any other Location. User should not be able to select Previous , Next buttons.


IF UserSetup.GET(USERID) THEN
BEGIN
UserSetup.TESTFIELD("Store No.");
IF (UserMgt.GetUserInfo2(USERID) <> '' )THEN BEGIN
SETRANGE("No.",UserMgt.GetUserInfo2(USERID));

END;
END;

Thanks

*This post is locked for comments

  • jsshivalik Profile Picture
    jsshivalik 3,027 on at
    RE: Filter Record

    Hi

     When i set the property Insert Allowed = No of Main Source table then it is working.

    Thanks

  • Suggested answer
    npanchal Profile Picture
    npanchal on at
    RE: Filter Record

    Looking at the code, If User Setup will not exist for user he/she can able to view all record.

    Please check the user setup for user you are in.

  • jsshivalik Profile Picture
    jsshivalik 3,027 on at
    RE: Filter Record

    Hi

       I have tried that but still it display 1 more record . 

    How FilterGroup(2),FilterGroup(1) works.


    IF UserSetup.GET(USERID) THEN
    BEGIN
    UserSetup.TESTFIELD("Location");
    IF (UserMgt.GetUserInfo2(USERID) <> '' )THEN BEGIN
    FILTERGROUP(2);
    SETRANGE("No.",UserMgt.GetUserInfo2(USERID));
    FILTERGROUP(0);
    END;
    END;


    //FILTERGROUP(2);

    Thanks

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Filter Record

    Remove your last statement FILTERGROUP(2).

  • jsshivalik Profile Picture
    jsshivalik 3,027 on at
    RE: Filter Record

    Hi

     I have put it here but same issue. When i press Next Button it displays one blank record

    Form - OnOpenForm()

    IF UserSetup.GET(USERID) THEN

    BEGIN

     UserSetup.TESTFIELD("location");

     IF (UserMgt.GetUserInfo2(USERID) <> '' )THEN BEGIN

       FILTERGROUP(2);

       SETRANGE("No.",UserMgt.GetUserInfo2(USERID));

       FILTERGROUP(0);

     END;

    END;

    FILTERGROUP(2);

  • npanchal Profile Picture
    npanchal on at
    RE: Filter Record

    Put it on Open Page.

  • jsshivalik Profile Picture
    jsshivalik 3,027 on at
    RE: Filter Record

    Hi

    Form - OnInit()

    Thanks

  • npanchal Profile Picture
    npanchal on at
    RE: Filter Record

    Which trigger are you putting your code?

  • jsshivalik Profile Picture
    jsshivalik 3,027 on at
    RE: Filter Record

    Hi Amol

     I have added the screenshot

    Thanks

  • jsshivalik Profile Picture
    jsshivalik 3,027 on at
    RE: Filter Record

    7853.Screen2.jpg7853.Screen2.jpg

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,219 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,056 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans