You need to sign in to do that
Don't have an account?
ApexLegend
SOQL Query IN not working
I have a Opportunity Trigger Handler were I want to create custom Sportsman__c records related to the created or updated Opportunity.
In case of Update, to find wheter the updated Opportunity already has Sportsman__c records, i execute the following:
Can someone help me with this issue?
In case of Update, to find wheter the updated Opportunity already has Sportsman__c records, i execute the following:
// check if trigger is update if (oldMap != null) { oldRecordList.addAll(oldMap.values()); System.debug('oldRecordList: ' + oldRecordList); // create list with sportsman records related to an opportunity sportsmanCheckList = [SELECT Id, Sportsman__c, Opportunity__c FROM Sportsman__c WHERE Opportunity__c IN :oldRecordList]; System.debug('Checklist: ' + sportsmanCheckList); System.debug('oldMap: ' + oldMap); for (Opportunity o : oldRecordList) { // put opportunities w/o sportsman records in opportunityWithoutSportsmanList for (Sportsman__c s : sportsmanCheckList) { if (o.Id != s.Opportunity__c) { opportunityWithoutSportsmanList.add(o); } } }The problem is that the sportsmanCheckList never gets filled, I suspect something is wrong with my SOQL query. But when I debug the oldRecordList it contains the updated Opportunity.
Can someone help me with this issue?
You woudl want to do something like this.
You would want to use Please let me know if that solves your problem.
Thanks!
I have understood your question and I guess You should query with oldRecordId rather than OldRecordList.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com (http://www.ajaydubedi.com )