Created
October 14, 2017 14:46
-
-
Save Eric-Guo/358d4a20934b9e8dad8bf5c58036b129 to your computer and use it in GitHub Desktop.
Export account from salesforce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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