Why doesn't this work? Hide when @Elements(@UserRoles)=0

I’d like to hide certain elements on an outline if a user is not a member of any role…

Why doesn’t this work?

Many thanks

Subject: Why doesn’t this work? Hide when @Elements(@UserRoles)=0

I’m guessing it is because @Elements(@UserRoles) can’t ever be 0, because even if the only element is “”, that is one element. You could use @UserRoles=“” isstead, which would work because you will never have a blank element if there are any user roles at all.

Subject: RE: Why doesn’t this work? Hide when @Elements(@UserRoles)=0

But @UserRoles=“” is not working either (sorry, I should have mentioned that)

and @elements(@userroles) computed text does produce a zero.

Subject: RE: Why doesn’t this work? Hide when @Elements(@UserRoles)=0

@elements(@userroles)”

It really should not (and it does not for me). @Elements should return 0 only, if it is fed a null string. That does not mean an empty string, but something like @Nothing.

Did you - to be on the sure side - close and reopen the client after granting or removing user roles? The problem you observe might just be down to caching.

Subject: RE: Why doesn’t this work? Hide when @Elements(@UserRoles)=0

Yes I did. And I deleted the cache.ndk

@UserRoles=“” or @Elements(@UserRoles)=0 does not work…

I read another posting somewhere on this site for another solution but I can’t get that working either:

!(@UserRoles *= “[Admin]”:“[RA]”:“[RB]”:“[RC]”)

http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/03324ef59663f8108525702f0020202b?OpenDocument

I would really appreciate any other suggestions… MANY thx

Subject: RE: Why doesn’t this work? Hide when @Elements(@UserRoles)=0

“And I deleted the cache.ndk”

Won’t make a difference. Since the advent of Notes 6, I think I deleted my cache.ndk once. And I don’t mean once per week, as in 4, but really once in total.

I come to think - even more after you posted the results of the code suggested by Stephen - that either something in your hide-when-formula must be fundamentally wrong (is there anything else in it?) or that this outline is corrupted. It definitely should work either way suggested.

Subject: RE: Why doesn’t this work? Hide when @Elements(@UserRoles)=0

So it should work?

You’ve hidden outline entries when a user is not in any role?

I will create a new db from scratch and let you know what happens.

Subject: RE: Why doesn’t this work? Hide when @Elements(@UserRoles)=0

I realized I forgot that the ACL was set on the views from ‘all readers’ to all 3 specific roles… but it they were set to the roles to which I and my test IDs are members. Sorry if that makes a difference. I was careful to save changes to the design elements with the admin id that has access to all and test with my id which I would put in and out of roles…

ok so I created a new db from scratch and that worked as expected.

I think it’s working on my db now. Here’s what I did which I think worked:

-changed the ACL in the views to allow all readers

-saved the outline with no hide when formulas

-tested, worked as expected

-edited the outline and saved some of the individual entries with the following hide when formula:

 num := 0;

 num := @Elements(@UserRoles);

 @If(num = 0; @True; @False)

-tested, worked as expected

-changed the view ACL back to exactly what I had before, based on roles

so far it appears to be working as expected.

Thanks for all your help!

Subject: Why doesn’t this work? Hide when @Elements(@UserRoles)=0

Curious, is it on a server or local?

Hide when do have some odd results. I know I once had the following and it wouldn’t work

x := “1”;

@GetField(“Fieldname_” + x) = “”

Hoping it would hide if the value was blank. This would NOT work but if I changed it to:

@GetField(“Fieldname_1”) = “”

It would work. Anyway back to yours have you thought

I just added the following action to Outline I’m working on:

@Prompt([Ok];“test”;“# elements=[” + @Text(@Elements(@UserRoles)) + “] and they are [” + @Implode(@UserRoles;@NewLine) + “]”)

and got… Maybe it will tell you/us something

Subject: RE: Why doesn’t this work? Hide when @Elements(@UserRoles)=0

Thanks. I took myself out of all the roles and used your code on an outline entry.

cam up with ‘[0] elements and they are

This is on the server BTW.

Subject: RE: Why doesn’t this work? Hide when @Elements(@UserRoles)=0

Weird OK, so to try things. What happens in your hide when if you do the following

num := 0;

num := @Elements(@UserRoles));

@if(num = 0; @True; @False)