All blog posts, code samples and downloads licensed under Apache License 2.0.
Close

Check for a user role - the right way

Oliver Busse on 12.02.2013 00:49:19 GMT, filed under SSJS Formula 

Most documentations show the code number 1 for checking if a user has a specific role. This may work if your applications runs in a browser only but will fail in the Notes client. The second version shows how to achieve this in both clients and it feels like the more elegant way. Winken

// number 1: this one works only in a browser
@IsMember(context.getUser().getRoles(), "[RoleName]")

// number 2: this will work in both client types
database.queryAccessRoles(session.getEffectiveUserName()).contains("[RoleName]")

Tagged with role acl