Search code examples
lotus-noteslotus-dominolotus-formula

Lotus Notes Client: How to determine user's role by click a button


I would like to ask how to use a button to determine user's role?

I have a form and a button. I created a role called tester in Access Control List (this is used to define user's role).

What I try to do is the button will check the user's role by click it. I mean if the user is in tester role, the user clicks it, no error occurs and no action will perform at this stage. If the user is not in tester role, when the user clicks the button at the first time, there will be a pop window/message box shows to the user, if the user click more than one time, another pop window/ message box shows to the user.

I put the following code in the button to perform the action I mentioned above. I checked there is no syntax error in the code.

temp := @If(disablebutton="1"; @Return(@Prompt([Ok];"";"You clicked this
button more than one time.")); @Prompt([Ok];"";"This is your first time 
to click this button."));
FIELD disablebutton:="1";

@If(@IsMember("[tester]";@UserRoles);@Success;temp)

When I try run to test the code, I notice that if the user is not in tester role, the user will receive the message, and that works fine.

But I don't understand when the user is in tester role, the user can get the message.

Grateful if someone can let me know what I did wrong in the code.

Thank you very much.

Yours faithfully,

beginner


Solution

  • You misunderstand Formula Language. Variables and fields are pretty much the same thing: they can contain values; they do not contain functions. (There are no subroutines.) When you assign something to a variable or a field, it is the value returned as a result of running a formula, not the formula itself. Most @Commands will return a 1 (@True) if they run successfully and a 0 (@False) if they don't.

    If there is something that you want to skip based on user roles, you would have to do it like this:

    @If(@IsMember("[tester]"; @UserRoles); @Return(""); "");
    

    as the first line of the formula. Or, at least, as the line before the place in the formula where you don't want your user to go. The line says "if the user has the role '[tester]', then exit this formula without doing anything, otherwise do nothing else on this line, but continue". Use "" as the do-nothing (no-op) in Formula Language; @Success should only be used for Field Validation formulas. So your formula becomes:

    @If(@IsMember("[tester]"; @UserRoles); @Return(""); "");
    @If(disablebutton="1"; @Return(@Prompt([Ok];"";"You clicked this
    button more than one time.")); @Prompt([Ok];"";"This is your first time 
    to click this button."));
    FIELD disablebutton:="1"