UserTerritory2Association lstUserTerritory = [SELECT Id, User.FirstName, User.LastName,Territory2.Name,Territory2Id, Territory2.Territory2Model.Name
FROM UserTerritory2Association WHERE UserId =: userinfo.getUserId() and IsActive = True];
if(lstUserTerritory != null && !lstUserTerritory.isEmpty()) {
for(UserTerritory2Association t : lstUserTerritory) {
TerritoriesList.add(new SelectOption(t.Territory2Id,t.Territory2.Name));
}
}
How to get the UserName and territory name assign to user in query?
1 Antwort
Hi Mohankumar,
Can you try below code -
List<UserTerritory2Association> lstUserTerritory = [SELECT Id, User.FirstName, User.LastName,Territory2.Name,Territory2Id, Territory2.Territory2Model.Name
FROM UserTerritory2Association WHERE UserId =: userinfo.getUserId() and IsActive = True];
if(lstUserTerritory != null && !lstUserTerritory.isEmpty()) {
for(UserTerritory2Association t : lstUserTerritory) {
TerritoriesList.add(new SelectOption(t.Territory2Id,t.Territory2.Name));
}
}
Thanks!