Skip to main content
added 50 characters in body
Source Link

Use an if condition to modify the query based on the UserInfo.getUserId.

Or, you could try this Query

SELECT Id, Name, StageName, CloseDate, Amount, 
Owner.Name, 
Owner.UserRole.DeveloperName, 
Owner.UserRole.Name
FROM Account
WHERE Id = :AccountId
AND OwnerId = :userId

And then filter the records based on the role.

Use an if condition to modify the query based on the UserInfo.getUserId.

Or, you could try this Query

SELECT Id, Name, StageName, CloseDate, Amount, 
Owner.Name, 
Owner.UserRole.DeveloperName, 
Owner.UserRole.Name
FROM Account
WHERE Id = :AccountId
AND OwnerId = :userId

Use an if condition to modify the query based on the UserInfo.getUserId.

Or, you could try this Query

SELECT Id, Name, StageName, CloseDate, Amount, 
Owner.Name, 
Owner.UserRole.DeveloperName, 
Owner.UserRole.Name
FROM Account
WHERE Id = :AccountId
AND OwnerId = :userId

And then filter the records based on the role.

added 216 characters in body
Source Link

Use an if condition to modify the query based on the UserInfo.getUserId.

Or, you could try this Query

SELECT Id, Name, StageName, CloseDate, Amount, 
Owner.Name, 
Owner.UserRole.DeveloperName, 
Owner.UserRole.Name
FROM Account
WHERE Id = :AccountId
AND OwnerId = :userId

Use an if condition to modify the query based on the UserInfo.getUserId.

Use an if condition to modify the query based on the UserInfo.getUserId.

Or, you could try this Query

SELECT Id, Name, StageName, CloseDate, Amount, 
Owner.Name, 
Owner.UserRole.DeveloperName, 
Owner.UserRole.Name
FROM Account
WHERE Id = :AccountId
AND OwnerId = :userId
Source Link

Use an if condition to modify the query based on the UserInfo.getUserId.