How to bulk delete Salesforce default datasets using RForcecom

August 22, 2018
By

(This article was first published on R – Data science & Software development, and kindly contributed to R-bloggers)

When you signed up a brand new Salesforce account, you can see lots of dummy dataset (such as Acme Inc.). If you are a Salesforce developer or administrator, you might have to delete all records prior to release the account to Salesforce users (And it is really painful job).

In this case, you can do delete such records at one time by using RForcecom.

Here is a very simple code (just 20 lines) to perform.

library("RForcecom")

username<-""
password<-""
token<-""

session<-rforcecom.login(username, paste0(password,token))

deleteAll<-function(objectName){
  df<-rforcecom.retrieve(session, objectName, c("Id"))
  deleteRecords <- function(id){
    x<-as.character(id)
    rforcecom.delete(session, objectName, id)
  }
  lapply(df$Id, deleteRecords)
}
deleteAll("Contact")
deleteAll("Opportunity")
deleteAll("Lead")
deleteAll("Account")
deleteAll("Campaign")
deleteAll("ContentDocument")

 

 

To leave a comment for the author, please follow the link and comment on their blog: R – Data science & Software development.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)