heroku/databasedotcom — Issue #41: Seems to be a maximum of 500 objects returned
Author: simonstearn
Created: 2011-12-08 19:01:13+00:00
State: open

I have about 1900 opportunities in sale force.com and I am trying to use ruby to script a complex report - but the code below seems to run into a maximum of 500 opportunities. I am probably doing something stupid - but what ?

require "rubygems"
require 'oa-oauth'
require 'yaml'
require 'databasedotcom'

puts("Reading Config")
config = YAML.load_file("salesforce.yml") rescue {}
client_id = ENV['DATABASEDOTCOM_CLIENT_ID'] || config["client_id"]
client_secret = ENV['DATABASEDOTCOM_CLIENT_SECRET'] || config["client_secret"]
debugging = ENV['DATABASEDOTCOM_DEBUGGING'] || config["debugging"]
host = ENV['DATABASEDOTCOM_HOST'] || config["host"]

puts ("Logging in ...")

connection = Databasedotcom::Client.new("salesforce.yml")
begin
puts("Authenticating:")
connection.authenticate(:username => config["user"], :password => config["password"])
puts("Done.")
rescue Databasedotcom::SalesForceError => err
connection = nil
puts "Bugger."
puts err.message
exit
end

puts ("Materializing Objects..")
connection.materialize("Account")
connection.materialize("Opportunity")

puts ("Done. Getting all opportunities..")

opno=0
Opportunity.all.each do | opportunity |
opno+=1
puts opno.to_s + ": " + opportunity.Exony_Opportunity_ID__c.to_s + " - " + opportunity.Name.to_s
end

puts "There were " + opno.to_s + " opportunities"

Thanks for your help.