You need to sign in to do that
Don't have an account?

Contains method on child to parent relationship query
I am trying to use the contains method on a string field in my relationship query for the list below but I get Compile Error: unexpected token: 'HSS'. To get to the field it is going from UserTerritory2Association to Territory2 to Territory2Type. (Child to Parent to Parent all standard objects) If I just say WHERE Territory2.Territory2Type.DeveloperName = 'HSS' then it works fine but I don't want to have to specify every single type. Instead I want to say if the type MasterLabel contains certain characters then it should grab those. Why is it not letting me use the contains method?
Thanks,
Amanda
List<userterritory2association> userTerritoryAssociations = [
Select id, UserID, territory2Id, RoleInTerritory2, Territory2.Territory2Type.Priority, Territory2.Territory2Type.MasterLabel from userterritory2association Where Territory2.Territory2Type.MasterLabel.contains( 'HSS' )
];
Thanks,
Amanda
List<userterritory2association> userTerritoryAssociations = [
Select id, UserID, territory2Id, RoleInTerritory2, Territory2.Territory2Type.Priority, Territory2.Territory2Type.MasterLabel from userterritory2association Where Territory2.Territory2Type.MasterLabel.contains( 'HSS' )
];