I was wondering why ArrayGetIndex is not used by developers more.
It basically returns an index number for the position of the value in an array or null if the element does not exist, BUT if the element does not exist ireturns null.
So to test use >=0 or stick isnull( <arraygetindex>)
So how does this work with userroles and roles?
Well you could do a
forall r in roles
if r="[Admin]" then admin=true
end forall
but a quicker way would be
If not isnull(Arraygetindex(db.QueryAccessRoles(s.EffectiveUserName),"[Admin]")) Then Msgbox("[Admin] is there")
or to check that Admin is not in the roles
If Isnull( Arraygetindex(db.QueryAccessRoles(s.EffectiveUserName),"[Admin]") ) Then Msgbox("[Admin] not there")
Example code:
Dim s As New notessession
Dim db As notesdatabase
Set db = s.currentdatabase
roles = db.QueryAccessRoles(s.EffectiveUserName)
Msgbox (Implode(roles,"--"))
If Isnull( Arraygetindex(roles,"[Admin]") ) Then Msgbox("[Admin] not there")
If Arraygetindex(roles,"[Admin]")>=0 Then Msgbox("[Admin] is there")