This question already has an answer here:
- how get i get user, userTerritory join? 2 answers
I need a query to take the name of the territory to which a user belongs I try with this
UserTerritory userT = [SELECT Id, Terrotory.Name FROM UserTerritory WHERE UserId = :currentUser LIMIT 1];
but throws this error
SELECT Id, Territory.Name ^ ERROR at Row:1:Column:12 Didn't understand relationship 'Territory' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.