Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

With APEX if you have a list of Ids like:

List<Id> customObjList

You can do one efficient SOQL query using the IN keyword.

SELECT ID,NAME from SObject WHERE Id IN :customObjList

I have to do a similar thing or something else which is efficient/best practice in JAVA.

I have an arrayList of Ids.

ArrayList<SObject> invoiceObjectlist

I am hoping I can use one SOQL query to get records with those Ids. If so how can I do this?

Thank you.

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

If you know their IDs and are using SOAP API , retrieve is much better than hand-crafting SOQL :)

Otherwise I'm afraid you'd have to create full query yourself, ...WHERE Id IN ('001...', '001...', '001') style

share|improve this answer
    
Very nice. retrieve() is something I was looking for. Also a quick question, I am thinking the answer is no. But when you do a mass create/Upsert you can get the IDs of the new records using getId() on the result object. Is there any way we can get the name of the record at this point as well? That would save me the retrieve() call. –  Richard N Dec 17 '12 at 17:48
4  
Nope only the id is available. Unless you explicitly set the name on the record. –  techtrekker Dec 17 '12 at 18:37
    
As @techtrekker said - I'm not aware of any. You need to query to get back autonumbers, fields that got default values, were set with workflows etc... That or write an apex webservice that'd insert, query & return it for you but sounds a bit of overkill unless you're really concerned about network bandwidth, count of API calls etc. –  eyescream Dec 17 '12 at 20:43
    
Ok thanks guys. Out of curiosity how would I retrieve the Name if it was being set explicitly at the time of doing the bulk Insert/Upsert call? –  Richard N Dec 17 '12 at 20:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.