<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/how-to-bulk-delete-salesforce-default-datasets-using-rforcecom/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://hiratake55.wordpress.com/2018/08/23/how-to-bulk-delete-salesforce-default-datasets/"> R – Data science &amp; Software development</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>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).</p>
<p><a rel="nofollow" href="https://hiratake55.files.wordpress.com/2018/08/screen-shot-2018-08-23-at-0-54-54.png" target="_blank"><img data-orig-file="https://hiratake55.files.wordpress.com/2018/08/screen-shot-2018-08-23-at-0-54-54.png" data-orig-size="2364,1414" data-medium-file="https://hiratake55.files.wordpress.com/2018/08/screen-shot-2018-08-23-at-0-54-54.png?w=300" data-attachment-id="748" data-image-meta="{" data-image-description="" src="https://hiratake55.files.wordpress.com/2018/08/screen-shot-2018-08-23-at-0-54-54.png?w=450&h=362&fit=605%2C362" data-permalink="https://hiratake55.wordpress.com/2018/08/23/how-to-bulk-delete-salesforce-default-datasets/screen-shot-2018-08-23-at-0-54-54/" data-large-file="https://hiratake55.files.wordpress.com/2018/08/screen-shot-2018-08-23-at-0-54-54.png?w=450&amp;h=362&amp;fit=605%2C362" alt="" data-image-title="Screen Shot 2018-08-23 at 0.54.54" sizes="(max-width: 605px) 100vw, 605px" data-comments-opened="1" class="wp-image-748" data-recalc-dims="1"></a></p>
<p>In this case, you can do delete such records at one time by using <a rel="nofollow" href="http://rforcecom.plavox.info/" target="_blank">RForcecom</a>.</p>
<p>Here is a very simple code (just 20 lines) to perform.</p>
<pre>
library(&quot;RForcecom&quot;)

username&lt;-&quot;&quot;
password&lt;-&quot;&quot;
token&lt;-&quot;&quot;

session&lt;-rforcecom.login(username, paste0(password,token))

deleteAll&lt;-function(objectName){
  df&lt;-rforcecom.retrieve(session, objectName, c(&quot;Id&quot;))
  deleteRecords &lt;- function(id){
    x&lt;-as.character(id)
    rforcecom.delete(session, objectName, id)
  }
  lapply(df$Id, deleteRecords)
}
deleteAll(&quot;Contact&quot;)
deleteAll(&quot;Opportunity&quot;)
deleteAll(&quot;Lead&quot;)
deleteAll(&quot;Account&quot;)
deleteAll(&quot;Campaign&quot;)
deleteAll(&quot;ContentDocument&quot;)
</pre>
<p>Â </p>
<p>Â </p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://hiratake55.wordpress.com/2018/08/23/how-to-bulk-delete-salesforce-default-datasets/"> R – Data science &amp; Software development</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/6r8ke5msG-s" height="1"></a></div>