You need to sign in to do that
Don't have an account?
amyer2240
SOQL query returning 0 results
I have a trigger that isn't working, and I think it's not working because of the SOQL query below. I'm creating a new record in sandbox that matches the criteria in the query and troubleshooting in the debug log - does anyone see any reason this might not work? Thank you!
My debug log looks like:
SYSTEM_CONSTRUCTOR_ENTRY [3]|<init>()
SYSTEM_CONSTRUCTOR_EXIT [3]|<init>()
SYSTEM_CONSTRUCTOR_ENTRY [5]|<init>(Integer)
SYSTEM_CONSTRUCTOR_EXIT [5]|<init>(Integer)
SYSTEM_METHOD_ENTRY [6]|MAP<Id,Opportunity>.keySet()
SYSTEM_METHOD_EXIT [6]|MAP<Id,Opportunity>.keySet()
SYSTEM_METHOD_ENTRY [9]|com.salesforce.api.interop.apex.bd.DateMethods.ValueOf(String)
SYSTEM_METHOD_EXIT [9]|com.salesforce.api.interop.apex.bd.DateMethods.ValueOf(String)
SOQL_EXECUTE_BEGIN [9]|Aggregations:0|select Id, cv__UniqueId__c, cv__Opportunity__r.Id, cv__Posted__c, cv__Reversed__c, cv__Posted_Date__c from cv__Relationship__c where (cv__UniqueId != null and cv__Reversed__c = false and cv__Posted__c = true and cv__Opportunity__r.Id = :tmpVar1 and cv__Posted_Date__c < :tmpVar2)
SOQL_EXECUTE_END [9]|Rows:0
List<Opportunity> opportunities = new List<Opportunity>(); Map<Id, Opportunity> opportunitiesById = new Map<Id, Opportunity>(opportunities); Set<Id> oppsset = new Set<Id>(); oppsset = opportunitiesbyId.keySet(); //get the opps and their relshps cv__Relationship__c[] relationships = [select Id, cv__UniqueId__c, cv__Opportunity__r.Id, cv__Posted__c, cv__Reversed__c, cv__Posted_Date__c from cv__Relationship__c where cv__UniqueId__c != null and cv__Reversed__c = false and cv__Posted__c = true and cv__Opportunity__r.Id in :oppsset and cv__Posted_Date__c < :Date.valueOf('2011-01-01')];
My debug log looks like:
SYSTEM_CONSTRUCTOR_ENTRY [3]|<init>()
SYSTEM_CONSTRUCTOR_EXIT [3]|<init>()
SYSTEM_CONSTRUCTOR_ENTRY [5]|<init>(Integer)
SYSTEM_CONSTRUCTOR_EXIT [5]|<init>(Integer)
SYSTEM_METHOD_ENTRY [6]|MAP<Id,Opportunity>.keySet()
SYSTEM_METHOD_EXIT [6]|MAP<Id,Opportunity>.keySet()
SYSTEM_METHOD_ENTRY [9]|com.salesforce.api.interop.apex.bd.DateMethods.ValueOf(String)
SYSTEM_METHOD_EXIT [9]|com.salesforce.api.interop.apex.bd.DateMethods.ValueOf(String)
SOQL_EXECUTE_BEGIN [9]|Aggregations:0|select Id, cv__UniqueId__c, cv__Opportunity__r.Id, cv__Posted__c, cv__Reversed__c, cv__Posted_Date__c from cv__Relationship__c where (cv__UniqueId != null and cv__Reversed__c = false and cv__Posted__c = true and cv__Opportunity__r.Id = :tmpVar1 and cv__Posted_Date__c < :tmpVar2)
SOQL_EXECUTE_END [9]|Rows:0
cv__UniqueId !=null,
cv__Reversed__c = false and all other cvonditions.
Hope this helps !!
Does the Map/List/Set format look ok?
Thank you!
Thank you!
Thank you!!
select Id, cv__UniqueId__c, cv__Opportunity__r.Id, cv__Posted__c, cv__Reversed__c, cv__Posted_Date__c
from cv__Relationship__c
where cv__UniqueId__c != null and cv__Reversed__c = false and cv__Posted__c = true and cv__Posted_Date__c = 2012-11-06T00:00:00Z
I tried to hardcode the date in my trigger, which now looks like:
but is still returning 0 rows. Any ideas?
Thank you!!
So,that's the issue here you need to see what value is coming there try debugging using System.debug() method and see the id what's there and use that id to run in the SOQL toll and see if you are getting any results.
I am sure you won't.
Hope this helps !!
Do you see anything wrong with the map/list combo? Thank you again for your help!
And got zero results. What?? Any help is apprecaited! Thank you!