You need to sign in to do that
Don't have an account?
Anu
Search multiple objects using ID
I have a list of IDs which holds IDs of Contacts or Leads. I would like to search for Lead and Contact using the list of IDs and the depening upon the return record type I want to add to Lead or Contact array list.
record = Search in Lead or Contact tables where ID = {ID from the list}
if record type = Lead then LeadArrayList.add(record)
if record type = Contact then ContactArrayList.add(record)
Thanks in advance.
Anu
Hi Anu,
I think the approach you will need to use is to create 2 lists. One for leads the other for contacts. You can separate the ids based on the first 3 characters of the id (prefix). The prefix for a contact is 003 and for a lead is 00Q (zero, zero, Q). These prefixes can be obtained by using the describeSObject call.
Once you have your 2 lists, you can make a retrieve call to get the contact data and a second retrieve call to get the lead data. The retrieve call takes a type (contact or lead), an array of ids and a list of fields to return. It returns SObjects that are of the requested type.
SObject[] results = SforceService.retrieve("Id, FirstName, LastName", "contact", new string[] {"id1", "id2", ...});
The key is that the ids should all be of the specified type.
Hope this helps.
Cheers