How to get the user roles using Groovy Script ?
(Doc ID 1662746.1)
Last updated on OCTOBER 31, 2023
Applies to:
Oracle Fusion CRM Application Composer Cloud Service - Version 11.1.7.0.0 and laterInformation 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
To view full details, sign in with your My Oracle Support account. |
|
Don't have a My Oracle Support account? Click to get started! |
In this Document
Goal |
Solution |
References |