function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
somasundaram s 7somasundaram s 7 

get Inactive roles from SFDC using SOQL

hi guys,

I will try getting Inactive roles using soql .I unable to do this.If you know kindly share to me .


Thanks ,
Somu
Jack Yu@TokyoJack Yu@Tokyo
Hi
Fields below is all the fields belong to UserRole object
ID
NAME
PARENTROLEID
ROLLUPDESCRIPTION
OPPORTUNITYACCESSFORACCOUNTOWNER
CASEACCESSFORACCOUNTOWNER
CONTACTACCESSFORACCOUNTOWNER
FORECASTUSERID
MAYFORECASTMANAGERSHARE
LASTMODIFIEDDATE
LASTMODIFIEDBYID
SYSTEMMODSTAMP
DEVELOPERNAME
PORTALACCOUNTID
PORTALTYPE
PORTALROLE
PORTALACCOUNTOWNERID

And There is no Active field at all.

【Inactive roles】 , do you mean the role is not used now? 
The SOQL below that you can get all roles that is not used. 

select id,name,DeveloperName from UserRole where id not in(select UserRoleId from user where UserRoleId != null )