Search code examples
ruby-on-railssalesforcedatabasedotcom-gem

Trying to show all contacts related to salesforce account


I'm using the databasedotcom gem to sync my app with salesforce, it pulls a list of all accounts perfectly, but I need to have a primary contact for each account, I currently have this:

<p>
    <b>License Contact:</b>
    <%= Account.contact(@customer.Id).Name %>
</p>

<p>
    <b>Email:</b>
    <%= Account.contact(@customer.Id).Email %>
</p>

<p>
    <b>Phone:</b>
    <%= Account.contact(@customer.Id).Phone %>
</p>

and @customer is defined in my controller as @customer = Account.find(params[:id])


Solution

  • Had a look at this link : http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_SOQL_variables.htm

    Which shows a few parameters and how to call them, I updated my code to this:

    @contact = Contact.find_by_AccountID(params[:id])
    

    Then called it in my view: <%= @contact.Name %> etc.