@KeyWords and @UserRoles Problem

I has the following formula:

view := “Menu Control Handler”;

key := “Menu Control Handler”;

FIELD AllowedPerson := @DbColumn(“”:“NoCache”;“”:“”;view;2);

FIELD AllowedRole := @DbColumn(“”:“NoCache”;“”:“”;view;3);

FIELD ExceptPerson := @DbColumn(“”:“NoCache”;“”:“”;view;4);

FIELD ExceptRole := @DbColumn(“”:“NoCache”;“”:“”;view;5);

FIELD Enable := @DbColumn(“”:“NoCache”;“”:“”;view;6);

@For(i:=1;i<=50;i:=i+1;FIELD Result := @If(i=1;@If((@IsMember(@UserName;@Explode(ExceptPerson[i];“,”)) & ExceptPerson[i] !=“”) | (@IsMember(@Explode(@UserRoles;“,”);@Explode(ExceptRole[i];“,”)) & ExceptRole[i] !=“”);“Not Show”;(@IsMember(@UserName;@Explode(AllowedPerson[i];“,”)) & AllowedPerson[i] !=“”) | (@IsMember(@Explode(@UserRoles;“,”);@Explode(AllowedRole[i];“,”)) & AllowedRole[i] !=“”);“Show”;@If(AllowedPerson[i] =“” & AllowedRole[i] =“” & ExceptPerson[i] =“” & ExceptRole[i] =“” & Enable[i] =“Disable”;“Show”; “Not Show”));Result : @If((@IsMember(@UserName;@Explode(ExceptPerson[i];“,”)) & ExceptPerson[i] !=“”) | (@IsMember(@Explode(@UserRoles;“,”);@Explode(ExceptRole[i];“,”)) & ExceptRole[i] !=“”);“Not Show”;(@IsMember(@UserName;@Explode(AllowedPerson[i];“,”)) & AllowedPerson[i] !=“”) | (@IsMember(@Explode(@UserRoles;“,”);@Explode(AllowedRole[i];“,”)) & AllowedRole[i] !=“”);“Show”;@If(AllowedPerson[i] =“” & AllowedRole[i] =“” & ExceptPerson[i] =“” & ExceptRole[i] =“” & Enable[i] =“Disable” ;“Show”; “Not Show”))));

Result

I want to hide the outline menu with the above fomrula, I has a document to stored the access right, however, it do not work when @UserRoles is multiple value.

I tried to such that for testing:

@Prompt([OK];“Title”;“User Roles=”+@UserRoles+“Roles=”+@Explode(@Implode(AllowedRole[1]))+“Result=”+@Keywords(@UserRoles;@Explode(@Implode(AllowedRole[1]))))

For example:

AllowedRoles contain [Finance], [Finance Manager]

and my ACL Roles are [Finance], [Admin], [Developer]

where AllowedRole[1] is multi-value and stored with and @UserRoles is also multi-value, how can I test my current roles is exist in the field AllowedRole (multi-value)?

Subject: RE: @KeyWords and @UserRoles Problem

Don’t use the FIELD keyword unless assigning a field in a document. For a temporary variable, not being saved in a document, leave out FIELD.

To see whether a list has at least one value in common with another list, use the expression list1 *= list2

Try not to use @UserRoles more than once – it’s a slow function. Store the return value in a temporary variable.

Don’t bother to @Explode(@UserRoles) because it’s already a list.

Hide formulas must return @True or @False; why create a list of “Show” and “Not Show” instead of a list of @True and @False?

Do the permissions change so often that you really need to use NoCache? It’s slower.

Rather than do 5 separate lookups, put all the data in one column and use delimiter characters to separate it out. Much faster.

view := “Menu Control Handler”;

massData := @DbColumn(“”:“NoCache”;“”:“”;view;2);

AllowedPerson := @Left(massData; “|”);

AllowedRole := @Word(massData; “|”; 2);

ExceptPerson := @Word(massData; “|”; 3);

ExceptRole := @Word(massData; |"; 4);

Enable := @Rightback(massData; “|”);

myroles := @UserRoles;

@For(i:=1;i<=@Elements(AllowedPerson;i:=i+1;

Result := Result +

@If(

@UserName = ExceptPerson[i] | (ExceptRole[i] != “” & myRoles *= @Explode(ExceptRole[i]; “,”)); “,1”;

@UserName = AllowedPerson[i] | (AllowedRole[i] != “” & myRoles *= @Explode(AllowedRole[i]; “,”)); “,0”;

Enable[i] =“Disable”;“,0”;

“,1”)

);

@TextToNumber(@Explode(Result; “,”))