[php]</p>
<p><?php </p>
<p>echo "Hello World! <br/><br/>"; </p>
<p>// Connect to Infusionsoft</p>
<p>require_once("isdk.php");<br />
$app = new iSDK;<br />
if ($app->cfgCon("sandbox")) { // 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 "You connected at $currentDate <br/><br/>";</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 -> Query the lead table to find the opportunities for this contact</p>
<p> $qryFields = array(‘Id’, ‘ContactID’, ‘StageID’);<br />
$query = array(‘ContactID’ => $contactId);<br />
$myOpp = $app->dsQuery("Lead",5,0,$query,$qryFields);</p>
<p> //Remove these three lines when done testing<br />
echo "<pre>";<br />
print_r($myOpp);<br />
echo "</pre>";</p>
<p>// Update the opportunity with the new stage</p>
<p> $update= array(‘StageID’ => $newStageId);<br />
$oppID = $myOpp[0][‘Id’]; // This line assumes there is only one opp fpr this contact<br />
$opp = $app->dsUpdate("Lead", $oppID, $update);</p>
<p> // Remove this line when done testing<br />
echo "<br/>Updated Opp ID# ".$opp." <br/>";</p>
<p>} else {<br />
echo "Not Connected…";<br />
} </p>
<p> [/php]
How To Change the Opportunity Stage
Written by
in
Leave a Reply