• naveenkumarbv
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 14
    Replies

Hi All,

 

I'm newbie on working with rails 3 and integrating the same with salesforce too. So far, working on this task has been very interesting.

I wanted to know how much time does it take to load contact(or any other) entity from salesforce.

 

I am using Ruby1.9.2/Rails 3.x as my development environment, and not using any particular gem to work on salesforce.

 

I've used OAuth2 - UserName Password flow to connect to salesforce, where I get an access token, and using this access_token for all subsequent requests to work with salesforce.

 

Before accessing salesforce each time I'm checking if an access_token is available to query salesforce.

 

If an access_token is available fine, else query for an access_token again and perform the operation.

 

And below are the list of fields I'm trying to fetch from Contact Entity

Id, FirstName, MiddleName__c, LastName, Email, Gender__c, MailingStreet, MailingCity, MailingState, MailingPostalCode, MobilePhone, MailingCountry 

 

On an average it takes around 1 to 2 sec or sometimes more than 2 secs(rarely) to fetch the records and display on my web page. 

 

So, can anyone give me some clarification on what is the normal query time to fetch data from Salesforce. And how do we handle such performance issues??

 

Thanks in Advance.

 

Regards,

Naveen Kumar B.V 

 

 

 

Hi All,

 

This may sound like a newbie question, I have started working on salesforce recently and a  bit stuck up on some implementations.

 

I am using the REST way to access salesforce - (OAuth2 to authenticate, and REST implementation to query Salesforce).

 

1. How do I impose a Unique Index constraint  on Email in CONTACT entity, basically I dont want to store duplicate email ids in Contact entities. How do we do it?

 

I have used Validation Rules to apply Mandatory Check on Email Column, but how do we impose a Unique Check.

 

2. Also, by default LastName in Contact entity is Mandatory. How to remove this mandatory check.

 

Can anyone help me regarding this?

 

Regards,

Naveen Kumar B.V

Hi,

 

I am using Ruby 1.9.2 and Rails 3.0.3, and OAuth2 username-passoword flow to work with salesforce.

Initially when I used WEBrick(without SSL) to connect to salesforce, I was not able to because it needed a HTTPS request, so I configured SSL in WEBrick by generating certificate files, etc and then everything worked fine.

 

Later, we had to switch to Mongrel, because WEBrick is not suitable for production use and also faced some problems with OpenId integration because WEBrick was not capable of handling large URLs.

 

We cannot configure SSL in Mongrel directly, so we have zeroed on using Apache server as SSL proxy to mongrel. Things were working  fine except for some URL redirect issues, etc.

 

But now, when I use ONLY MONGREL and performed the same operations with salesforce like (Saving a CONTACT, Retreiving a CONTACT based on email) and that too without SSL, everything was still working fine.

 

Please confirm if ONLY HTTP Request works well with salesforce, or is it mandatory to use HTTPS. I am a bit confused regarding this.

 

Regards,

Naveen Kumar B.V

Hi,

 

This may seem to be a trivial issue, but I need some help to solve this.

 

I am trying to query salesforce Contact entity using REST api from a RoR application.

I am able to retrieve all the Contact entities information  successfully when I only use a simple select query like:

 

@uri.get({:q => 'select id, firstname, lastname from Contact'}, headers) do |callback|
      callback.on_ok do |response|
        self.replace(response.deserialise['records'].map do |contact|
          Contact.new(@salesforce_session,
            'FirstName' => contact["FirstName"], 'LastName' => contact["LastName"], 'Id' => contact["Id"]
          )
        end)
      end

 

 

But, I am getting a 400 Bad Request error when using the where clause with the above statement:

 

@uri.get({:q => 'select id, firstname, lastname from Contact where email = "naveen@gmail.com"'}, headers) do |callback|
      callback.on_ok do |response|
        puts "******************* Printing Response ********************"
        puts response.inspect
        self.replace(response.deserialise['records'].map do |contact|
          Contact.new(@salesforce_session,
            'FirstName' => contact["FirstName"], 'LastName' => contact["LastName"], 'Id' => contact["Id"]
          )
        end)
      end

 

LOG:

 

Loading details by email id........
<- (GET -3363550491 -217275911) https://ap1.salesforce.com:443/services/data/v20.0/query?q=select+id%2C+firstname%2C+lastname+from+Contact+where+email+%3D+%22naveen%40gmail.com%22
-> (GET -3363550491 -217275911) 400 Bad Request (230 bytes 2.15s)

 

 

 I understand that there is something wrong in the Request used to query salesforce. How do I ensure that the request format is correct while using a 'WHERE' clause.

 

Thank You,

Naveen Kumar B.V


Hi All,

 

I'm newbie on working with rails 3 and integrating the same with salesforce too. So far, working on this task has been very interesting.

I wanted to know how much time does it take to load contact(or any other) entity from salesforce.

 

I am using Ruby1.9.2/Rails 3.x as my development environment, and not using any particular gem to work on salesforce.

 

I've used OAuth2 - UserName Password flow to connect to salesforce, where I get an access token, and using this access_token for all subsequent requests to work with salesforce.

 

Before accessing salesforce each time I'm checking if an access_token is available to query salesforce.

 

If an access_token is available fine, else query for an access_token again and perform the operation.

 

And below are the list of fields I'm trying to fetch from Contact Entity

Id, FirstName, MiddleName__c, LastName, Email, Gender__c, MailingStreet, MailingCity, MailingState, MailingPostalCode, MobilePhone, MailingCountry 

 

On an average it takes around 1 to 2 sec or sometimes more than 2 secs(rarely) to fetch the records and display on my web page. 

 

So, can anyone give me some clarification on what is the normal query time to fetch data from Salesforce. And how do we handle such performance issues??

 

Thanks in Advance.

 

Regards,

Naveen Kumar B.V 

 

 

 

Hi All,

 

This may sound like a newbie question, I have started working on salesforce recently and a  bit stuck up on some implementations.

 

I am using the REST way to access salesforce - (OAuth2 to authenticate, and REST implementation to query Salesforce).

 

1. How do I impose a Unique Index constraint  on Email in CONTACT entity, basically I dont want to store duplicate email ids in Contact entities. How do we do it?

 

I have used Validation Rules to apply Mandatory Check on Email Column, but how do we impose a Unique Check.

 

2. Also, by default LastName in Contact entity is Mandatory. How to remove this mandatory check.

 

Can anyone help me regarding this?

 

Regards,

Naveen Kumar B.V

Hi,

 

This may seem to be a trivial issue, but I need some help to solve this.

 

I am trying to query salesforce Contact entity using REST api from a RoR application.

I am able to retrieve all the Contact entities information  successfully when I only use a simple select query like:

 

@uri.get({:q => 'select id, firstname, lastname from Contact'}, headers) do |callback|
      callback.on_ok do |response|
        self.replace(response.deserialise['records'].map do |contact|
          Contact.new(@salesforce_session,
            'FirstName' => contact["FirstName"], 'LastName' => contact["LastName"], 'Id' => contact["Id"]
          )
        end)
      end

 

 

But, I am getting a 400 Bad Request error when using the where clause with the above statement:

 

@uri.get({:q => 'select id, firstname, lastname from Contact where email = "naveen@gmail.com"'}, headers) do |callback|
      callback.on_ok do |response|
        puts "******************* Printing Response ********************"
        puts response.inspect
        self.replace(response.deserialise['records'].map do |contact|
          Contact.new(@salesforce_session,
            'FirstName' => contact["FirstName"], 'LastName' => contact["LastName"], 'Id' => contact["Id"]
          )
        end)
      end

 

LOG:

 

Loading details by email id........
<- (GET -3363550491 -217275911) https://ap1.salesforce.com:443/services/data/v20.0/query?q=select+id%2C+firstname%2C+lastname+from+Contact+where+email+%3D+%22naveen%40gmail.com%22
-> (GET -3363550491 -217275911) 400 Bad Request (230 bytes 2.15s)

 

 

 I understand that there is something wrong in the Request used to query salesforce. How do I ensure that the request format is correct while using a 'WHERE' clause.

 

Thank You,

Naveen Kumar B.V


Hello everyone, I've been working on a little product catalog application using the REST api. I've got my authentication going with OAuth2, and can query my custom object just fine. I'm working on the update method. I've gotten to the point where I get an HTTP 415 error, which is unsupported media type. I have an update_hash that I'm trying to pass. I've tried these various forms of the hash:

 

update_hash

  = speed3.25 mph

update_hash.to_json

  = {"speed":"455 mph"}

update_hash.dump

 = "{\"speed\":\"455 mph\"}"

 

 

Now this last one looks like how it should be sent. When using the OAuth2 Gem, and this:

 

resp = @access_token.post("#{@resturl}/sobjects/StarkT1__Terminator__c/#{id}?_HttpMethod=PATCH", update_hash, {"ContentType" => "application/json"})

 

I receive this error:

 

undefined method `merge' for "\"{\\\"speed\\\":\\\"455 mph\\\"}\"":String

 

So it looks like the @access_token.post() is doing it's own conversion. Just passing in the hash gives me the 415 error though. So I thought I'd try a RestClient.post and see what happens:

 

resp = RestClient.post("#{@resturl}/sobjects/StarkT1__Terminator__c/#{id}?_HttpMethod=PATCH", update_hash, :content_type => :json, :authorization => "OAuth #{@saccess_token}")

 

This gives me an http 400, bad request. Trying different versions of the update_hash seems to always give me an http 400 error, so something else is wrong with my RestClient post.

 

Any of you gurus out there can tell at a glance what I'm doing wrong?

 

Thanks,

Jed

  • March 23, 2011
  • Like
  • 0

Hello,

 

I want to display Contact/Account records in Ruby app. using OAuth.

Can anybody tell me how to use OAuth in Ruby to access salesforce data?

 

Your help will be highly appreciated.

 

Waiting for early response.

 

Thanks in advance,

  • March 09, 2011
  • Like
  • 0

Hello,

 

I am trying to write the SOQL statement that will let me select only contacts that belong to the triggering account in a trigger, atm I have:

 

    Contact[] cntList = [ SELECT c.Phone
                          FROM Contact c
                          WHERE Contact.AccountId = Account.Id
                          FOR UPDATE];

 

but the SOQL seems unhappy with the Account.Id field... giving the error:

 

Error: Compile Error: unexpected token: 'Account.Id' at line 9 column 52

 

I am new to APEX and Salesforce, I was hoping for either a nice link to some resources I can learn from, or perhaps an explanation on the error of my ways

 

Thanks alot.

First, thanks for any help from the community and to Quinton for his development efforts, I am grateful.

 

I'm writing to express my frustration at what seems to me to be prolific yet out of date and conflicting documentation regarding SalesForce and Rails integration.

 

Is the "force.com toolkit for ruby" the rforcedotcom gem?

 

As of today, should developers be using activesalesforce, activerecord-salesforce-adapter, or asf-soap-adapter?

 

I haven't been able to accomplish my simple goal: creating a Rails 3.0.4 application that allows me to execute, from the console, Salesforce::SfBase.query_by_sql("select name from Account")

 

rails new someapp

cd someapp

bundle install

script/console

(explosion)

 

Given that my Gemfile states:

 

source 'http://rubygems.org'

gem 'rails', '3.0.4'
gem 'sqlite3'
gem 'asf-soap-adapter'

 

 

And my database.yml states:

 

development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

salesforce-default-realm:
  adapter: activesalesforce
  url: https://www.salesforce.com
  username: xxx
  password: xxx
  api_version: 20.0

 And my current gemset includes only the following:

 

abstract (1.0.0)
actionmailer (3.0.4)
actionpack (3.0.4)
activemodel (3.0.4)
activerecord (3.0.4)
activerecord-activesalesforce-adapter (2.0.0)
activeresource (3.0.4)
activesalesforce (1.1.6)
activesupport (3.0.4)
arel (2.0.8)
asf-soap-adapter (1.3.0)
builder (2.1.2)
bundler (1.0.10)
erubis (2.6.6)
facets (2.8.4)
hpricot (0.8.3)
i18n (0.5.0)
mail (2.2.15)
mime-types (1.16)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack-test (0.5.7)
rails (3.0.4)
railties (3.0.4)
rake (0.8.7)
rforcedotcom (20.0.0)
sqlite3 (1.3.3)
thor (0.14.6)
treetop (1.4.9)
tzinfo (0.3.24)

 

 

This should freakin' work. But it doesn't. Upon executing rails console:

 

/Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/activerecord-3.0.4/lib/active_record/connection_adapters/abstract/connection_specification.rb:62:in `establish_connection': salesforce-default-realm database is not configured (ActiveRecord::AdapterNotSpecified)
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/asf-soap-adapter-1.3.0/lib/salesforce/sf_base.rb:61
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/asf-soap-adapter-1.3.0/lib/asf-soap-adapter.rb:4:in `require'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/asf-soap-adapter-1.3.0/lib/asf-soap-adapter.rb:4
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `require'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
	from /Users/ybakos/tmp/sftest02/config/application.rb:7
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/railties-3.0.4/lib/rails/commands.rb:21:in `require'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/railties-3.0.4/lib/rails/commands.rb:21
	from script/rails:6:in `require'
	from script/rails:6

 

If anyone has successfully created a skeletal Rails 3.x app and has been able to fire up the console and execute Salesforce::SfBase.query_by_sql("select name from Account")

 


Then please do share what steps you took, and what your Gemfile and database.yml state.

 

  • February 15, 2011
  • Like
  • 0