Help with a VISIBLE instruction

DarkHorseDarkHorse Member Posts: 389
Dear folks, on OnOpenform from a form I've the instruction:

CurrForm.field.VISIBLE(USERID<>'USER');

It's to prevent some usersview a given field, it runs well. I want put more than an user but I don't know how. How should be the code, please?. Also, in this case, how should be not VISIBLE instruction?
Thanks in advance.

Comments

  • mohana_cse06mohana_cse06 Member Posts: 5,504
    IF USERID = 'USER' THEN
    CurrForm.field.VISIBLE:=FALSE;
  • DarkHorseDarkHorse Member Posts: 389
    Thanks but doesn't works. I put several users and hide the field correctly, but, following, enter an user that can see the field but it remains hide. The field is a boolean type one, I don't know if it can be a reason. Any other solution please?.
    Thanks for help.
  • SaalekSaalek Member Posts: 181
    Hi

    I think is better if you use CASE instruction
    Case USERID of
    'USER1': CurrForm.field.VISIBLE:=FALSE;
    'USER2': CurrForm.field.VISIBLE:=FALSE;
    'USER3': CurrForm.field.VISIBLE:=FALSE;
    'USER4': CurrForm.field.VISIBLE:=FALSE;
    else
    CurrForm.field.VISIBLE:=TRUE;
    end;

    Regards
  • DarkHorseDarkHorse Member Posts: 389
    That's right!!! =D> , it works; thanks for help.
    Best regards.
  • matttraxmatttrax Member Posts: 2,309
    That is horrible coding. You have required the customer to come back to you every time they want to give a new user permission to view / not view that field.

    How about a separate form with standard NAV security? Some people have access to one form, others have access to the other form.

    Not as good, but a flag in user setup would also do the trick. If the field allowing permission for that field is checked for the user, show the field, otherwise hide it.

    The solution you have written, although it does the job, is the worst way to do it.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    matttrax wrote:
    That is horrible coding. You have required the customer to come back to you every time they want to give a new user permission to view / not view that field.

    How about a separate form with standard NAV security? Some people have access to one form, others have access to the other form.

    Not as good, but a flag in user setup would also do the trick. If the field allowing permission for that field is checked for the user, show the field, otherwise hide it.

    The solution you have written, although it does the job, is the worst way to do it.

    I agree 100%.

    I have a client that has code like this all through their database, written by their partner. In the end they went out and bought the Solution developer and Application Builder, because that was cheaper in the long run that what it cost their partner to keep adding users.
    David Singleton
  • DenSterDenSter Member Posts: 8,304
    matttrax wrote:
    That is horrible coding.
    <snip>
    The solution you have written, although it does the job, is the worst way to do it.
    Yes indeed :shock:
  • kapamaroukapamarou Member Posts: 1,152
    matttrax wrote:
    That is horrible coding.
    :thumbsup:

    One additional comment. If your code is on the OnOpen trigger of a list form then what will happen if the use Right-clicks the column header and selects "Show Clumn"?

    There are solutions but I think the best approach is to use different forms with permissions.
  • SaalekSaalek Member Posts: 181
    DenSter wrote:
    matttrax wrote:
    That is horrible coding.
    <snip>
    The solution you have written, although it does the job, is the worst way to do it.
    Yes indeed :shock:

    Or you can add a new boolean field in User Setup (T91) Table.

    And all the code is reduced to 2 lines

    If TuserSetup.get(USERID) then;
    currform.control.visible:=TUserSetup."New field";

    Regards
  • David_SingletonDavid_Singleton Member Posts: 5,479
    kapamarou wrote:
    matttrax wrote:

    There are solutions but I think the best approach is to use different forms with permissions.

    Exactly

    :thumbsup:
    David Singleton
  • DenSterDenSter Member Posts: 8,304
    Saalek wrote:
    If TuserSetup.get(USERID) then;
    Why are you using an IF statement without any code?
  • idiotidiot Member Posts: 651
    DenSter wrote:
    Saalek wrote:
    If TuserSetup.get(USERID) then;
    Why are you using an IF statement without any code?

    viewtopic.php?f=23&t=33597 :lol:
    NAV - Norton Anti Virus

    ERP Consultant (not just Navision) & Navision challenger
  • DenSterDenSter Member Posts: 8,304
    idiot wrote:
    I knew that was out there too, I was wondering if anyone would notice :mrgreen:
  • krikikriki Member, Moderator Posts: 9,110
    Can I add an extra way to do it?
    http://www.mibuso.com/forum/viewtopic.php?t=38353.

    I think this way is the best version of all : No need to maintain 2 forms and no need to reprogram to add/remove a user.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.