You need to sign in to do that
Don't have an account?
Daniel Martins 4
Error in Territory Name
Hi Guys,
I need to get the Name of the Territory to assign it to a field, but when I try it, it generates an error.
this is my code:
List<UserTerritory> myList = [SELECT Id, UserId, TerritoryId
FROM UserTerritory
WHERE UserId = :UserInfo.getUserId()];
Set<Id> territoryIds = new Set<Id>();
for(UserTerritory terr : myList) {
territoryIds.add(terr.TerritoryId);
}
List<Territory> territoryN = new List<Territory>([SELECT Id, Name
FROM Territory
WHERE Id = :territoryIds LIMIT 1]);
System.debug('NAME TERRITORY******' + territoryN.Name);
in the System.Debug I need view the Name (territoryN.Name) and the error is "Variable does not exist: Name"
Please help me
I need to get the Name of the Territory to assign it to a field, but when I try it, it generates an error.
this is my code:
List<UserTerritory> myList = [SELECT Id, UserId, TerritoryId
FROM UserTerritory
WHERE UserId = :UserInfo.getUserId()];
Set<Id> territoryIds = new Set<Id>();
for(UserTerritory terr : myList) {
territoryIds.add(terr.TerritoryId);
}
List<Territory> territoryN = new List<Territory>([SELECT Id, Name
FROM Territory
WHERE Id = :territoryIds LIMIT 1]);
System.debug('NAME TERRITORY******' + territoryN.Name);
in the System.Debug I need view the Name (territoryN.Name) and the error is "Variable does not exist: Name"
Please help me
You are accessing a list just a like a record, which isn't allowed or I should say SF will not identify which record Name need to display.
So try like this
Or,
if you like to query only one record.
This will help. Let me know if you still face some error.
Thanks,
Gaurav
Skype: gaurav62990
Can you close this post. By marking it as solved.
Thanks,
Gaurav
skype: gaurav62990