How can I get a user's resource role using Groovy?
Here's a sample Groovy script that you can use to find a signed-in user's role code:
def vo = newView('Resource');
def vc = vo.createViewCriteria()
def vcr = vc.createRow()
def vci1 = vcr.ensureCriteriaItem('PartyId')
vci1.setOperator('=')
vci1.setValue(adf.util.getUserPartyId())
vc.insertRow(vcr)
vo.appendViewCriteria(vc)
vo.executeQuery()
def roleIter = vo.first()?.ResourceRoleAssign;
def roleRow;
def roleCode;
while (roleIter.hasNext())
{
roleRow = roleIter.next();
roleCode = roleRow?.RoleCode;
}
return roleCode;
If you need to end date an assigned resource role in an organization, you can do that using the fields mentioned in the Groovy script and in these fields:
ResourceOrg
RoleCode
ResourceOrgMemRoleStartDate
ResourceOrgMemRoleEndDate
See the Groovy Scripting Reference for more information on using Groovy scripting.