@contains, @ismember not working

I want to use the “hide action when formula is true” I want to write a formula that checks if the current user is in the author field. If he is, he can see the action. Else he can’t.Now, I thought I could use the @contains or @ismember function for this purpose. But neither of them is working.

I used:

@If(@IsMember(@UserName;Author_Field);@False;@True)

and

@If(@Contains(Author_Field;@UserName);@False;@True)

So I decided to test these functions.

I created two fields. Test and Test2

Test2 has a default value: “Bram”

Test has a default value:

@If(@IsMember(“Bram”;Test2);FIELD Test := “True”;FIELD Test := “False”)

Now, if I’m correct the field Test should say True. But it keeps saying False.

I tried also the @contains function:

@If(@Contains(Test2;“Bram”);FIELD Test := “True”;FIELD Test := “False”)

Same problem.

What am I doing wrong because I really can’t

understand this?

Greetz

Subject: thanks, but

Okay thanx guys, the test works fine now. But how I can make this formula work to hide my action. (action is also only visible in read-mode)

@If(@Contains(Author_Field;@UserName);@False;@True)

Every user has a manager, when a document is created, the manager is filled in my author_field. When the manager opens the document created by the user, he should be able to see the action. the user himself can’t see this action.

Lotus seems do it at random. This formula worked for 2 minutes, and after that it didn’t work anymore. I’m starting to go crazy with this mess. thanks at advance

Okay, I’m gonna edit this post, because I figured something out.

User creates form. User saves form. (Is redirected to the view after saving)

Case 1:

User doesn’t open the document he created.

After that the manager opens the document and can see the action.

Case 2:

The user opens the document he just created.

After that the manager opens the document and doesn’t see the action.

How is this possible?

Subject: RE: thanks, but

Lotus seems do it at random. This formula worked for 2 minutes, and after that it didn’t work anymore. I’m starting to go crazy with this mess. thanks at advance.

Well it’s not randsom. You need to examine the differences between the code working, and the hide-when failing again: what are the differences? Are you saying it works / doesn’t work for the same user, for the manager, who? Does the hide-when fail when other things come into play? (document status / edit or read mode, etc.)

You’re comparing a value in the field with @UserName: is that a guaranteed “like with like” comparison? For example, if “Author_Field” reads thus: “Fred Bloggs/ACME/EMEA”, it won’t compare properly with @UserName for Fred Bloggs. Also, “Author_Field” is always going to have one manager’s name in it, I wouldn’t bother with @Contains, just use a straight equality test (which is marginally less expensive than @Contains to boot).

Other things to consider when trouble-shooting your hide-whens:

Order of field evaluation (as mentioned before)

Nature of hide-when: is it over a rich text field? If so, this can alter in the front-end easily enough (edit a document with a rich text field in it, and note that end-users can define hide-when formula in rich text fields.

Subject: RE: thanks, but

The manager can be different for every user, it can be possible that the user even is the manager of another user.I can’t say: @if( = ) ,… unfortunately. If the @UserName is equal to a value of my authorfield, then isn’t this allways the case? And not one time it is, and another time it isn’t.And there is no order of field evaluation in my case I think, there’s just an action in read-mode which appearance is limited by the hide when formula. The author_field is allready a fixed value if a document is in read-mode, because the author field is computed when composed. It doesn’t change afterwards.

But maybe there’s something seriously wrong, because I also have problems with my user access, the reader and author fields don’t do what they’re supposed to do. For example, a user is not in the reader field of a document. This user can still see the document in the view (allthough he can’t read or edit it). When the user creates a document, then suddenly he can only see the documents he’s supposed to see. It’s one crazy fucked up mess …

Subject: RE: thanks, but

Are you testing this by switching ID’s in the client ? That can cause problems as the Notes Cache does not always seem to “forget” about the first user.

Rule of tumb : If you want to test with a second ID, and you are having trouble with getting access to things that that ID should not see, try restarting the client to see if that resolves the issue.

Subject: RE: thanks, but

Oh okay Ben, I see. No it’s a multiple value field. There’s also a role in that field. But now I understand you about the @contains could be unneccessary.I read everything about reader fields I could find on this forum, I also read the FAQ. But I simply can’t get it right. Don’t know why. I made a post last week with all the information about my problems with reader and author fields.

Graham, no I test it via internet explorer (it’s a web application). Every time I start the application in IE there’s asked for a username and password.

Subject: RE: thanks, but

The manager can be different for every user, it can be possible that the user even is the manager of another user.I can’t say: @if( = ) ,… unfortunately. If the @UserName is equal to a value of my authorfield, then isn’t this allways the case? And not one time it is, and another time it isn’t.

You misunderstand me. Is “Author_Field” a single value field? If so, you don’t need to do @Contains. You simply need to test the current user ID against the ID detailed in the “Author_Field” field. The fact that managers vary from document to document is irrelevant.

As for Readers fields not working, there are a number of things to check: see the forum FAQ for more pointers.

Subject: RE: thanks, but

Bram,

A couple of things. First, the @False, @True is unnecessary in a hide formula. I think the problem may be due to evaluation of the name conventions. I’d do it this way;

name1:= @Name([CN] ; Author_Field);

name2:= @Name([CN] ; @UserName);

!@Contains(name1; name2);

Subject: @contains, @ismember not working

I tried your formula with @Contains and I could get it working.You have to make sure that the field Test2 appears BEFORE the field Test on the form. A form is sequential evaluated.

Subject: @contains, @ismember not working

I tried your test, and it worked for me. Here’s what I did:

Created a form containint two text fields: Test1 & Test2.

Test1 is editable, with a default value “Bram” : “Gram” : “Pram” (note the delimiters so that this is a proper list)

Test2 is computed, with the following formula: @If(@IsMember(“Bram”;Test1); “True”; “False”)

Creating a doc with this form results in “True”, as expected, in Test2.

I then edited Test1 so that “Bram” didn’t appear, refreshed the document, and Test2 re-computed to “False” – again, as expected. Finally, I removed everything in Test1 bar “Bram” – “True” again.

Some points to consider:

If you’re computing a value based upon a field, the field you’re testing needs to come before the results field in normal circumstances.

If you’re using formula to compute a field, you don’t need to refer to that field explicitly in the code (i.e. no need for @If(@IsMember(“Bram”;Test2);FIELD Test := “True”;FIELD Test := “False”) as in your code).

If your formula is simply used to calculate a default value, it will only compute initially (i.e. in the example above, removing “Bram” from the list and refreshing the document doesn’t result in a change in value from “True” to “False”).

HTH