3

I have a view called "vwTest" which has one column and lists 3 docs:

John Mcoy
Peter Pap
Ashley Young

I have a picture with a default hotspot on which I typed the following Hide when formula:

view := "vwTest";
nume := @Name([CN];@UserName);
@If(@IsMember(nume;_view);@False;@True)

The user is John Mcoy. But the picture is hidden. Why? Thanks!

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
Florin M.
  • 2,159
  • 4
  • 39
  • 97

1 Answers1

4

You have to check if your user is in first (sorted) column of your view. You can do that with @DbLookup. Your hide formula would look like this:

@DbLookup("":"NoCache"; ""; "vwTest"; @Name([CN];@UserName); 1; [FAILSILENT]) = ""

It returns @True if the username is not in view's first column.

[FAILSILENT] let @DbLookup return an empty string if the key username is not found in column.

In your question's code you just test if username is member of string "vwTest" which of course is never the case.

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
  • I changed my answer completely as I understood your question different in the first place. – Knut Herrmann Aug 23 '13 at 07:27
  • Actually, in the question's code it's even worse: the variable he assigns the view name to is "view", but the variable he tests is "_view". – Richard Schwartz Aug 23 '13 at 13:22
  • @ Db... functions are "expensive" - the delay to execute them depends on many factors (server configuration, document count, complexity of view...) and may (will) slow down form opening as your database grow. In hide-when it is easily overlooked and whole formula may be cloned just by hitting enter on that paragraph - so hide-when specifically is the worst place to have @ DbLookup in. The workaround is to use computed for display field with @ DbLookup and use its value in hide-when. – Frantisek Kossuth Oct 08 '13 at 13:34
  • @Frantisek: agree with "easily overlooked" and "be cloned". Computed for display field is a good way to make this formula more visible. – Knut Herrmann Oct 08 '13 at 13:46