restrict user

tatietatie Member Posts: 16
Is it possible to limit users to see/modify on a form without using Roles/Permissons.

Comments

  • krikikriki Member, Moderator Posts: 9,118
    Yes, but you have to hardcode it in every form you want to block (the list contains the user that cannot open/modify the form):

    To avoid opening the form:
    OnOpenForm-trigger:

    IF USERID IN THEN
    currform.close;
    OR also
    IF USERID IN THEN
    ERROR('YOU CANNOT OPEN THIS FORM'); // but of course with a text-constant!

    To avoid modifying :
    OnOpenForm-trigger:
    CurrForm.EDITABLE(NOT (USERID IN ));
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • HalMdyHalMdy Member Posts: 429
    Same as kriki, without Hardcoding :

    In table UserSetup, create Boolean Fields corresponding to permissions you want to manage.
    So , in the code from kriki, simply replace condition with

    IF UserSetup.GET(USERID) AND (UserSetup.Condition) THEN ...

    Hope can help ...
  • tatietatie Member Posts: 16
    Thanks for yours replies
    I'm sorry, my question is not precise enough
    I start again

    The goal is to forbidden users to access to the record of sales order Form, while an another user already accessing to the same order (record).

    I thank you
  • sblotsblot Member Posts: 21
    With SQL server you can manage permission as record level!

    regards
  • krikikriki Member, Moderator Posts: 9,118
    -If you mean this : if a user X has a certain record A in the form, than user Y cannot see this record? => This is not possible.

    -If you mean this : if user X created sales order A, then only he or a superuser can see it? => create a new field in T36 ("Created By User"), fill it up with the userid of the user.
    OnOpenForm-trigger:
    recMemberOf.RESET;
    recMemberOf.SETCURRENTKEY("User ID","Role ID",Company);
    recMemberOf.SETRANGE("User ID",USERID);
    recMemberOf.SETRANGE("Role ID",USERID);
    recMemberOf.SETFILTER(Company,"%1|%2",COMPANYNAME,'');
    IF NOT recMemberOf.FIND('-') THEN BEGIN
    // the user is NOT a superuser in current company, so he can only see his own orders
    FILTERGROUP(6);
    SETRANGE("Created By User",USERID);
    FILTERGROUP(0);
    END;
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.