Get started

1. Install the latest version of R.

You can download the latest R from the R-Project website.
http://cran.r-project.org/

2. Install the RForcecom and load.

Type the commands from your R console.

install.packages("RForcecom")
library(RForcecom)

3. Sign in to the Force.com (Salesforce.com).

To sign in to the Force.com, use rforcecom.login() function. Set username, password, instanceURL, APIversion as follows.
Instance URL (ex: https://na14.salesforce.com/) is shown in your Force.com (Salesforce.com) page.

username <- "yourname@yourcompany.com"
password <- "YourPasswordSECURITY_TOKEN"
instanceURL <- "https://xxxx.salesforce.com/"
apiVersion <- "25.0"
session <- rforcecom.login(username, password, instanceURL, apiVersion)

4. Execute a SOQL

To retrieve the dataset using SOQL, use rforcecom.query() function.

soqlQuery <- "SELECT Id, Name, Industry, AnnualRevenue FROM Account"
rforcecom.query(session, soqlQuery)

5. Creating a record

To insert the record, use rforcecom.create() function.

objectName <- "Account"
fields <- c(Name="R Analytics Service Ltd", Phone="5555-5555-5555")
rforcecom.create(session, objectName, fields)

6. Retrieving a record

To retrieve the dataset, use rforcecom.retrieve() function.

objectName <- "Account"
fields <- c("name", "Industry", "AnnualRevenue")
rforcecom.retrieve(session, objectName, fields)

7. Updating a record

To update a record, use rforcecom.update() function.

objectName <- "Account"
id <- "999x000000xxxxxZZZ"
fields <- c(Phone="9999-9999-9999")
rforcecom.update(session, objectName, id, fields)

8. Upsert a record

To upsert a record, use rforcecom.upsert() function.
The word “upsert” means if a record exists update the field, if not insert a record.

objectName <- "Account";
externalIdField <- "AccountMaster__c"
externalId <- "AM-00000151"
fields <- c(Name="ABC Network Company", Phone="3333-3333-3333")
rforcecom.upsert(session, objectName, externalIdField, externalId, fields)

9. Deleting a record

To update a record, use rforcecom.delete() function.

objectName <- "Account";
id <- "999x000000xxxxxZZZ"
rforcecom.delete(session, objectName, id)

10. Execute a SOSL

To query a SOSL, use rforcecom.search() function.

queryString <- "United"
rforcecom.search(session, queryString)

11. Retrieve a server timestamp

To retrieve a server timestamp from Salesforce.com server, use rforcecom.getServerTimestamp() function.

rforcecom.getServerTimestamp(session)