Skip to content

Instantly share code, notes, and snippets.

@Eric-Guo
Created October 14, 2017 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Eric-Guo/358d4a20934b9e8dad8bf5c58036b129 to your computer and use it in GitHub Desktop.
Save Eric-Guo/358d4a20934b9e8dad8bf5c58036b129 to your computer and use it in GitHub Desktop.
Export account from salesforce
require 'restforce'
require 'csv'
client = Restforce.new :username => 'admin@bayekeji.com',
:password => '',
:client_id => '3MVG9Z',
:client_secret => '8211'
hsh_ary = client.query("select Id, LastName, DetailAddress__c from account where DetailAddress__c != null")
rowid = 0
CSV.open('address_details.csv', 'w') do |csv|
hsh_ary.each do |hsh|
rowid += 1
if rowid == 1
csv << %w(Id LastName DetailAddress__c)
else
csv << [hsh.Id, hsh.LastName, hsh.DetailAddress__c]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment