There's not much information around for the Force.com CLI, so I'm keeping a list of things here for posterity...
If it's not a big list, just pipe that back into a CSV object and iterate over it, deleting each one with "force record delete"
It's not very fast, so if there's a lot of them you'll need to use the bulk API. First remove the quotes from the CSV, no idea why, but "force bulk" hates them for some reason. Then call it like this:
If you just have a medium-sized list of IDs to delete and they're not in a CSV (e.g. copypasta from elsewhere), just paste them right into the command line as one big string and .Split() them, like this:
Check out the output from just the part inside the parentheses to see all the other metadata you can use.
Deleting:
First, write the list of records to a file (you could just save to a variable but it can come in handy to keep a list of IDs when modifying records)force query "SELECT Id FROM Object__c WHERE Field__c = 'Whatever'" | Out-File .\ids_to_delete.csv
If it's not a big list, just pipe that back into a CSV object and iterate over it, deleting each one with "force record delete"
Import-Csv .\ids_to_delete.csv | % { force record delete Object__c $_.Id }
It's not very fast, so if there's a lot of them you'll need to use the bulk API. First remove the quotes from the CSV, no idea why, but "force bulk" hates them for some reason. Then call it like this:
force bulk delete Object__c .\ids_to_delete.csv
If you just have a medium-sized list of IDs to delete and they're not in a CSV (e.g. copypasta from elsewhere), just paste them right into the command line as one big string and .Split() them, like this:
"axxx000000xxxxxAAA axxx000000xxxxxAAA etc".Split(" ") | % { force record delete Object__c $_ }
Inserting:
Put all your data into a CSV file with the exact same column headings as the Salesforce fields, and then:force bulk insert Object__c .\new_object_data.csv
Querying Metadata:
For getting a list of fields, which I need to do all the time:(force describe -t=sobject -n=Object__c | convertfrom-json).fields | select name
Check out the output from just the part inside the parentheses to see all the other metadata you can use.
Comments
Post a Comment