Get started

1. Install the latest version of R.

You can download the latest R from the R-Project website.

2. Install the RForcecom and load.

Type the commands from your R console.


3. Sign in to the (

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

username <- ""
password <- "YourPasswordSECURITY_TOKEN"
instanceURL <- ""
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 function.

queryString <- "United", queryString)

11. Retrieve a server timestamp

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