You need to sign in to do that
Don't have an account?
Mayank Srivastava (Salesforce fan)
One questions about this code snippet
I took this directly off David's blog (http://www.sfdc99.com/2014/02/18/quiz-answers-chapter-4/). Is it possible to use a lead object(dupe) to store contents of a List variable? What purpose does it serve?
dupe = [SELECT Id, Potential_Lead_Dupe__c, Potential_Contact_Dupe__c FROM Lead WHERE Id = :dupe.Id];
dupe = [SELECT Id, Potential_Lead_Dupe__c, Potential_Contact_Dupe__c FROM Lead WHERE Id = :dupe.Id];
Lead dupe = new Lead(); dupe.FirstName = 'Frodo'; dupe.LastName = 'Baggins'; dupe.Company = 'Shire'; insert dupe; dupe = [SELECT Id, Potential_Lead_Dupe__c, Potential_Contact_Dupe__c FROM Lead WHERE Id = :dupe.Id]; System.assertEquals(lead1.Id, dupe.Potential_Lead_Dupe__c); System.assertEquals(ctc1.Id, dupe.Potential_Contact_Dupe__c);
Do you want to store the SOQL query result in Dupe variable? if yes then please create a list<lead> to store the SOQL result as it will return the list.
Thanks,
Pratik
You probably misunderstood my question. If you see the code snippet I posted above (it works since it's from David's site and I didn't write it), that is using dupe (an instance of Lead object) to store a SOQL query result. Are we allowed to do that?
The dupe variable is first declared as an object instance and then the same variable is used for storing a SOQL query result and that is what confuses me.