Requirements
- A Displayr document.
- A Salesforce account with valid user credentials and a security token from Profile icon > Settings > Reset My Security Token.
Please note these steps require a Displayr license.
Method
1. Select Data Sources > Plus (+) > R.
2. Enter a name for the data set under Name.
3. Paste the below R code where it states "Enter your R code here":
# Get authentication details
username <- 'yourusername'
userpw <- 'yourpassword'
token <- 'yoursecuritytoken'
password.token <- paste(userpw,token,sep="")
# Run query
library(RForcecom)
session <- rforcecom.login(username, password.token)
# Execute a SOQL
query <- "SELECT account.ID, account.Name FROM Account"
accounts <- rforcecom.query(session, query)
- Note, you will need to replace your username, password and security token with the appropriate user credentials.
- This query uses the RForcecom R package which logs into Salesforce using your credentials and then executes your query. In this example, we are calling the account ids and names.
- Salesforce utilizes a variation of standard SQL called Salesforce Object Query Language (SOQL). See the Salesforce SOQL Documentation library for details on how to structure SOQL syntax.
3. OPTIONAL: If you wish to make this call take place daily, you can add the below lines to the top of your R code:
library(flipTime)
UpdateEvery(1, "days", options = "wakeup")
See How to Automatically Update Calculations, Variables and Data Sets Using R for further details.
4. OPTIONAL: You can test the R code first via the Calculation icon > Custom Code until you have it working as this method allows for troubleshooting.
Next
Once you've imported your data, it's always a good idea to Check Your Data.