function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jaymin Sutarwala 7Jaymin Sutarwala 7 

Need help with SOQL query

Hi all,
I have written the following query in Opportunity Territory Assignment Apex Class. This query is not returning any result in the code. I tried execuring the query in Workbench but it is not returning any records.
SELECT Id, ObjectID, Territory2Id, Territory2.Territory2Type.MasterLabel, Territory2.ParentTerritory2Id FROM ObjectTerritory2Association WHERE SObjectType = 'Account' AND Territory2.Territory2ModelId = :activeModelId
However if I remove the condition SObjectType = 'Account' from the query and run it, it returns records. Any idea why the query is not working with the condition SObjectType = 'Account'

User-added image

 
Jaymin Sutarwala 7Jaymin Sutarwala 7
Guys,
Can anyone help with this one. Stuck with this for couple of days now.