Skip to main content


Showing posts from April, 2018

Using the CLI and Powershell

Inserting or Updating: Put all your data into a CSV file with the exact same column headings as the Salesforce fields, again making sure to save as ASCII and not UTF8 or any other encoding (in Excel, you want the option called "CSV (Comma delimited)" not "CSV UTF-8"). And then do this:

force bulk insert Object__c .\new_object_data.csv

To modify fields for updating, don't do the updates in Excel unless you have to - do it inline like this:

force query --format json "Select whatever from Object" | ConvertFrom-Json | %{$_.Some_Field__c = 'whatever'; $_} | select Id,Some_Field__c | Export-Csv .\updates.csv -NoTypeInformation -Encoding ASCII

Note the following:
The foreach (%) block at the end it returns the object being iterated over. This is really important otherwise it won't pipe anything through to the "select".
Speaking of the "select", you have to select only the fields you're working with, because "force q…