You need to sign in to do that
Don't have an account?
Madhuri Londhe
sObject type 'UserRole' is not supported
I have a triger condition which checks wheather user role exists in custom setting or not.
so for this i have a method where U do query on UserRole object.
I receive below error:
execution of BeforeUpdate caused by: System.QueryException: sObject type 'UserRole' is not supported.
for normal users i dont receive this error. But as system admin I receive email fro this and I am not able to find the cause.
please let me know the reason/cause for this and for which user we should expect this?
so for this i have a method where U do query on UserRole object.
I receive below error:
execution of BeforeUpdate caused by: System.QueryException: sObject type 'UserRole' is not supported.
for normal users i dont receive this error. But as system admin I receive email fro this and I am not able to find the cause.
please let me know the reason/cause for this and for which user we should expect this?
Can you try to check same using workbench with sys admin and other user?
Thanks,
Vinay Kumar
I did query as system admin as well other user it giver me output without any error.
Are you using any helper class for your trigger. If yes, than classes operate With Sharing by default when called from a trigger. So it might be an issue related to the permissions.
If possible, please paste your code so that we can have a better understanding of your issue.
Thanks,
Abhishek Bansal.
Yes I am using helper class for my trigger and it is with sharing.
Below is the code from helper class:
private static boolean IsValidUser;
public static Set<String> GetRoles()
{
return UserRoleole_Settings__c.getAll().keySet();
}
public static boolean IsValidUser()
{
if (IsValidUser != null)
{
return IsValidUser;
}
Set<String> roles = Helper.GetRoles();
Map<Id, UserRole> userRoles = new Map<Id, UserRole>([
SELECT
Id
FROM
UserRole
WHERE
Name IN :roles]);
IsValidUser = userRoles.containsKey(UserInfo.GetUserRoleId());
return IsValidUser;
}
If it is a permission issue what permission is missing and for which profile? How can I identify this?
Below is mail content:
Apex script unhandled trigger exception by user/organization: 0052000000423PG/00D20000000Lqzc
OpportunityTrigger: execution of BeforeUpdate
caused by: System.QueryException: sObject type 'UserRole' is not supported.
Class.Helper.IsValidUser: line 709, column 1
Can you please take help from the link given below:
https://salesforce.stackexchange.com/questions/222068/system-queryexception-sobject-type-opportunitylineitem-is-not-supported
Thanks,
Abhishek Bansal.