How To Change the Opportunity Stage

[php]</p>
<p>&lt;?php </p>
<p>echo &quot;Hello World! &lt;br/&gt;&lt;br/&gt;&quot;; </p>
<p>// Connect to Infusionsoft</p>
<p>require_once(&quot;isdk.php&quot;);<br />
$app = new iSDK;<br />
if ($app-&gt;cfgCon(&quot;sandbox&quot;)) { // Make sure this matches your connection name in conn.cfg</p>
<p>// Recipe starts here</p>
<p> // Current date in Infusionsoft-friendly format</p>
<p> $currentDate = date_format(date_create(), ‘YmdTH:i:s’);<br />
echo &quot;You connected at $currentDate &lt;br/&gt;&lt;br/&gt;&quot;;</p>
<p> $contactId = 129; // Dritte Dawg<br />
$newStageId = 24; // Change this StageID to whatever you want it to change it to</p>
<p> // API Call -&gt; Query the lead table to find the opportunities for this contact</p>
<p> $qryFields = array(‘Id’, ‘ContactID’, ‘StageID’);<br />
$query = array(‘ContactID’ =&gt; $contactId);<br />
$myOpp = $app-&gt;dsQuery(&quot;Lead&quot;,5,0,$query,$qryFields);</p>
<p> //Remove these three lines when done testing<br />
echo &quot;&lt;pre&gt;&quot;;<br />
print_r($myOpp);<br />
echo &quot;&lt;/pre&gt;&quot;;</p>
<p>// Update the opportunity with the new stage</p>
<p> $update= array(‘StageID’ =&gt; $newStageId);<br />
$oppID = $myOpp[0][‘Id’]; // This line assumes there is only one opp fpr this contact<br />
$opp = $app-&gt;dsUpdate(&quot;Lead&quot;, $oppID, $update);</p>
<p> // Remove this line when done testing<br />
echo &quot;&lt;br/&gt;Updated Opp ID# &quot;.$opp.&quot; &lt;br/&gt;&quot;;</p>
<p>} else {<br />
echo &quot;Not Connected…&quot;;<br />
} </p>
<p> [/php]

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *