I'm trying to do a staggered query using the Bulk API from a RoR app since the filter (WHERE App_Id__c IN :listOfIds) I'm using is over 4000 chars. The list of IDs I'm filtering on is quite long, so I'd love to slice it into smaller sections and make n queries to the Bulk API, building up an array of results.

I tried the below but it seems like the request never goes through:

private_class_method def self.salesforce_apps(ids)
  allsalesforceapps = []
  ids.each_slice(200) do |customer_ids_batch|
    allsalesforceapps  << Salesforce.bulk_client.query("App__c", "SELECT Id FROM App__c WHERE App_Id__c IN ('#{customer_ids_batch}')")


Any ideas?

  • I think you may be taking the wrong approach, but I'm not sure. What's the source of the list of ID values you're querying from? It might be easier to just perform a sub-query if possible. – sfdcfox Oct 19 '18 at 23:07
  • Hey sfdcfox, we tried to use a subquery but found that we really need the specific list of App IDs, is there any way to stagger these querys and build up a list? – McD Oct 22 '18 at 17:23
  • The Bulk API is used to asynchronously retrieve a large number of records that meet a specific SOQL that you can fit into the normal rules. Trying to do what you're doing will quickly exhaust your API daily limits. You should use either a sub-query filter or a child sub-query on the parent object. You need to take a step back and focus on the larger picture. – sfdcfox Oct 22 '18 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.