How to get the user roles using Groovy Script ? (Doc ID 1662746.1)

Last updated on NOVEMBER 07, 2016

Applies to:

Oracle Fusion CRM Application Composer Cloud Service - Version 11.1.7.0.0 and later
Information in this document applies to any platform.

Goal

A global script is written to return 'true' if the current logged user is having a specific role. The below code returns 'false' for the user 'XXX', while it returns true and works fine for other users having their role same as that of 'XXX'.

Script:
--------------
def userName = adf.context.getSecurityContext()?.getUserName()
def vo = newView('Resource')
adf.util.applyFilter(vo, [Username: userName])
vo.executeQuery()
if(vo.hasNext()) {
  def r = vo.next()
  def x = r?.Roles.toString()
 if (x == 'Operation Executive' || x == 'Operation Supervisor' || x == 'Country Operation Manager' || x == 'Operation Supervisor' || x == 'Sales Administrator') {
    return true
  }
  else {
    return false
  }
}
else {
  return false
}
--------------

Solution

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms