Skip to content

Instantly share code, notes, and snippets.

@ianhenrysmith
Created December 13, 2016 15:55
Show Gist options
  • Select an option

  • Save ianhenrysmith/1c0765b7212ef09a3f19bce498d9250f to your computer and use it in GitHub Desktop.

Select an option

Save ianhenrysmith/1c0765b7212ef09a3f19bce498d9250f to your computer and use it in GitHub Desktop.
require "restforce" # Salesforce::SignedRequest needs restforce
signed_request_string = "" # get a signed request string for this
signed_request = Salesforce::SignedRequest.new(raw_request: signed_request_string)
parsed_client = signed_request.parsed_request["client"]
client = Restforce.new(
oauth_token: parsed_client["oauthToken"],
refresh_token: parsed_client["refreshToken"],
instance_url: parsed_client["instanceUrl"],
client_id: ENV["SALESFORCE_CLIENT_ID"],
client_secret: ENV["SALESFORCE_CLIENT_SECRET"],
api_version: "38.0"
)
description = client.describe
opportunity_id = "00641000006QhJcAAK" # or any opportunity id
opportunity = client.find("Opportunity", opportunity_id)
opportunity_description = client.describe("Opportunity")
custom_relationships = opportunity_description.fields.select(&:custom).select{ |field| field.type =="reference"} # all custom relationships
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment