salesforce, I have 50k records in csv file which has Id column, I want to check whether records exist in salesforce through workbench. How do I query?

Viewed 265

I have 50 k records with Id field. I need to check whether this records exist or not and import into file if exists . How do I query against salesforce workbench with this huge count

SELECT Id FROM Account WHERE Id IN('XXXXX','YYYYY')

I am using above query but it takes huge time and even wonder even workbench allow query these many records.

1 Answers

SOQL can handle queries up to 100K characters.

  • 18-digit id + 2 commas and semicolon = 21 chars
  • SELECT Id FROM Account WHERE Id IN() = 37 chars
  • (100000 - 37) / 21 = 4760

It won't fit, you will have to cut it up into smaller queries.

If Workbench still timeouts - you could try using the bulk api option and download the CSV later (try with a smaller query say LIMIT 100 to see how it works). Or install Data Loader?

Why do you need to do it? If you plan to know which ones need insert, which ones need update - there's upsert operation that will do the mapping for you.

There's one more trick but it sounds bit stupid. "Screw it, update them all". Prepare file with just these Ids and load it as update operation. No other fields, it'll be as if user hit edit and save withotu changing anything, just last modified date. Then examine error file for ids SF couldn't find, success file for successes (or in SF go SELECT Id FROM Account WHERE LastModifiedDate = TODAY AND LastModifiedBy.Name = 'Ashok')

Related