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
Anu YadavAnu Yadav 

soql query on opportunity

Hi,
I m using following query in my batch class where i m retrieving opportunity records whose account owner is not same as its owner.

Id EBPRecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Partner Opportunities').getRecordTypeId();
        return Database.getQueryLocator([Select Id,name,AccountId,StageName,OwnerId,Account.OwnerId From Opportunity WHERE  OwnerId!=:Account.OwnerId and StageName IN ('Chance identified','Chance qualified','First offer','Finale offer') and RecordTypeid =: EBPRecordTypeId]);

getting error : Invalid bind expression type of Schema.SObjectField for column of type Id

Thanks,
Anu
Best Answer chosen by Anu Yadav
Anu YadavAnu Yadav
In query i was getting the error. I was comparing OwnerId!=:Account.OwnerId in soql where clause which is not correct. I resolved it by creating a formula field.
 

All Answers

Muzammil BajariaMuzammil Bajaria
in which line you are getting this error? in querry or while retrieving record type Id?
Anu YadavAnu Yadav
In query i was getting the error. I was comparing OwnerId!=:Account.OwnerId in soql where clause which is not correct. I resolved it by creating a formula field.
 
This was selected as the best answer