<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>cathylopez.com &#187; API calls</title>
	<atom:link href="http://cathylopez.com/tag/api-calls/feed/" rel="self" type="application/rss+xml" />
	<link>http://cathylopez.com</link>
	<description>sharing some random thoughts</description>
	<lastBuildDate>Sun, 22 Jan 2012 08:43:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Batch Update SObject in Salesforce.Com (VB.Net)</title>
		<link>http://cathylopez.com/2009/05/19/batch-update-sobject-in-salesforcecom-vbnet/</link>
		<comments>http://cathylopez.com/2009/05/19/batch-update-sobject-in-salesforcecom-vbnet/#comments</comments>
		<pubDate>Mon, 18 May 2009 16:04:53 +0000</pubDate>
		<dc:creator>cathy</dc:creator>
				<category><![CDATA[Salesforce.com]]></category>
		<category><![CDATA[API calls]]></category>
		<category><![CDATA[batch update]]></category>
		<category><![CDATA[salesforce.com]]></category>
		<category><![CDATA[sObject]]></category>
		<category><![CDATA[vb.net]]></category>

		<guid isPermaLink="false">http://cathylopez.com/?p=90</guid>
		<description><![CDATA[I&#8217;m sharing this code because I know a lot of new salesforce developers are pulling their hair out looking for concrete samples on how to do API batch update. Yes it took me awhile to be able to solve this problem. APEX API documentation doesn&#8217;t give it all and it&#8217;s frustrating&#8230; So much for that, [...]]]></description>
			<content:encoded><![CDATA[<p><img title="salesforcedice" src="http://cathylopez.com/wp-content/uploads/2009/05/salesforcedice.jpg" alt="salesforce dice" width="105" height="100" align="right" /></p>
<p>I&#8217;m sharing this code because I know a lot of new salesforce developers are pulling their hair out looking for concrete samples on how to do API batch update. Yes it took me awhile to be able to solve this problem. APEX API documentation doesn&#8217;t give it all and it&#8217;s frustrating&#8230;</p>
<p>So much for that, here&#8217;s how I did it. My sample is updating a custom field in Opportunity Object using VB.Net.<br />
<br /><script type="text/javascript"><!--
google_ad_client = "pub-3719025517760366";
google_ad_slot = "9581001184";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<br /></p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Dim</span> arrUpdateID <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> ArrayList  <span style="color: #008080; font-style: italic;">'This ArrayList holds the Opportunity IDs I need to update, I didn't included the query - that will be your task</span>
&nbsp;
<span style="color: #0600FF;">Dim</span> objOppx<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">199</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">As</span> Opportunity
&nbsp;
<span style="color: #FF8000;">For</span> d <span style="color: #008000;">=</span> d <span style="color: #FF8000;">To</span> arrUpdateID.<span style="color: #0000FF;">Count</span> <span style="color: #008000;">-</span> <span style="color: #FF0000;">1</span>
&nbsp;
<span style="color: #0600FF;">Dim</span> updateOppx <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> Opportunity
&nbsp;
updateOppx.<span style="color: #0000FF;">Id</span> <span style="color: #008000;">=</span> arrUpdateID<span style="color: #000000;">&#40;</span>d<span style="color: #000000;">&#41;</span> <span style="color: #008080; font-style: italic;">' You need an ID when you update</span>
updateOppx.<span style="color: #0000FF;">Downloaded__c</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span> <span style="color: #008080; font-style: italic;">' This is a checkbox in SFDC where I'm setting it to true</span>
updateOppx.<span style="color: #0000FF;">Downloaded__cSpecified</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span> <span style="color: #008080; font-style: italic;">' This is required when updating a boolean field</span>
objOppx<span style="color: #000000;">&#40;</span>d<span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> updateOppx <span style="color: #008080; font-style: italic;">' Storing opportunity values to  objOppx which is an array of Oppty</span>
&nbsp;
<span style="color: #FF8000;">Next</span>
&nbsp;
<span style="color: #0600FF;">Dim</span> sr<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">As</span> SaveResult <span style="color: #008000;">=</span> sfdc.<span style="color: #0000FF;">update</span><span style="color: #000000;">&#40;</span>objOppx<span style="color: #000000;">&#41;</span> <span style="color: #008080; font-style: italic;">' This is where the updating happens, this line of code should be outside the loop</span>
&nbsp;
<span style="color: #FF8000;">For</span> j <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">To</span> sr.<span style="color: #0000FF;">Length</span> <span style="color: #008000;">-</span> <span style="color: #FF0000;">1</span>
<span style="color: #0600FF;">Dim</span> msgerr <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>
&nbsp;
<span style="color: #0600FF;">If</span> <span style="color: #804040;">Not</span> sr<span style="color: #000000;">&#40;</span>j<span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">success</span> <span style="color: #FF8000;">Then</span>
msgerr <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;Error updating Opportunity ID: &quot;</span> <span style="color: #008000;">+</span> sr<span style="color: #000000;">&#40;</span>j<span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">id</span> <span style="color: #008000;">+</span> <span style="color: #808080;">&quot;. The error was: &quot;</span> _
<span style="color: #008000;">+</span> sr<span style="color: #000000;">&#40;</span>j<span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">errors</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">message</span>
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
&nbsp;
<span style="color: #FF8000;">Next</span></pre></div></div>

<p>Note: You can only update 200 records in an Object at a time due to Governor limits, so you need to make some work around with that issue. I have done that through chunking up my array of IDs to update. I&#8217;ll leave that up to you! <img src='http://cathylopez.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I hope this post helps! There will be more to come as I learn Salesforce.com and APEX programming.</p>
<p>Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://cathylopez.com/2009/05/19/batch-update-sobject-in-salesforcecom-vbnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

