Is there any API method to find the roleId using role name? I am getting the role name(s) form an excel sheet, I need to check, whether the role name exists or not.
If role exist
how can I assign that role to user?
If role doesn't exist,
how can I create the role first and then assign that role to user?
My code,
if(role != null && !role.isEmpty()){
Role currentRole=RoleLocalServiceUtil.getRole(companyId,role.trim());
if(currentRole != null)
{
roleId = currentRole.getRoleId();
}
else{
Role newRole = RoleServiceUtil.addRole(role.trim(), null, null, 0);
roleId = newRole.getRoleId();
}
}