You need to sign in to do that
Don't have an account?
SOQL trouble
I'm missing something fundamental - I need to get the Owner, Number of Leads, and the role description of the lead owners on a single SOQL statement. I'm trying the following:
SELECT Lead.Owner.Alias,Owner.Id, Lead.Owner.UserRoleId,
Lead.Owner.UserRoleId.Name, Count(Id)
FROM Lead
WHERE Lead.Owner.IsActive = TRUE
AND IsUnreadByOwner = True
GROUP BY Lead.Owner.Alias, Lead.Owner.Id, Lead.Owner.UserRoleId, Lead.Owner.UserRoleId.Name
HAVING Count(Id) < 25
ORDER BY Lead.Owner.Alias ASC
LIMIT 45
...but I get
INVALID_FIELD:
ERROR at Row:2:Column:1 Didn't understand relationship 'UserRoleId' in field path.
If I don't try to return "Lead.Owner.UserRoleId.Name" it works fine... which I'm thinking is because I'm mixing child-to-parent and parent-to-child, but I thought that since I already grabbed Lead.Owner.UserRoleId successfully I could also get the name.
Is there any way to do this?
Thanks in advance
KC64
Hi ,
try this query :
SELECT Lead.Owner.Alias,Owner.Id, Lead.Owner.UserRoleId,
Lead.Owner.UserRole.Name, Count(Id)
FROM Lead
WHERE Lead.Owner.IsActive = TRUE
AND IsUnreadByOwner = True
GROUP BY Lead.Owner.Alias, Lead.Owner.Id, Lead.Owner.UserRoleId, Lead.Owner.UserRole.Name
HAVING Count(Id) < 25
ORDER BY Lead.Owner.Alias ASC
LIMIT 45
Please mark it as the solution if it answers your question so that others can also take benifit.
Ckeck My Blog
All Answers
Hi ,
try this query :
SELECT Lead.Owner.Alias,Owner.Id, Lead.Owner.UserRoleId,
Lead.Owner.UserRole.Name, Count(Id)
FROM Lead
WHERE Lead.Owner.IsActive = TRUE
AND IsUnreadByOwner = True
GROUP BY Lead.Owner.Alias, Lead.Owner.Id, Lead.Owner.UserRoleId, Lead.Owner.UserRole.Name
HAVING Count(Id) < 25
ORDER BY Lead.Owner.Alias ASC
LIMIT 45
Please mark it as the solution if it answers your question so that others can also take benifit.
Ckeck My Blog
Thanks again, Niket!
Sorry for the cross-posting, I just didn't know which forum would get a resonse.
Double-thanks for posting the solution twice :-)
KC64
No problem Kevin. I am happy to help ..