Eliana,
this is what you would do!
You would have your form like you want process
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Add information To Leads</title>
</head>
<body>
<center><img src="http://www.salesforce.com/us/assets/developer/adn_logo.gif" alt="" border="0"></center>
<form action="process.php" method="post">
<table width="40%" align="left">
<tr>
<td>Would you like more information: </td>
<td>Yes<input type="radio" name="yes" value="yes" /></td>
<td>No<input type="radio" name="no" value="no" /></td>
<input type="hidden" name="leadid" value="<?php echo $_GET['leadid']; ?>" />
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="submit"></td>
</tr>
</table>
</form>
</body>
</html>
you would then send the ID in a hidden field, you can see that in a form. The action of the form, in this case, is a script called process.php
PHP Code:
<?php
ini_set("soap.wsdl_cache_enabled", "0");
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
require_once ('./includes/soapclient/SforcePartnerClient.php');
require_once ('./includes/soapclient/SforceHeaderOptions.php');
if (isset($_POST['submit']))
{
$_POST['id'] = $_POST['leadid'];
unset($_POST['leadid']);
$username = 'you@youremail.com';
$password = 'password';
$key = 'iwx7bDGIU0OCOOwnaKa0llSfY';
//setup update to Salesforce
//Go get the accounts by $account_name
try
{
//salesforce wsdl
$wsdl = './includes/soapclient/partner.wsdl.xml';
//connect to salesforce
$client = new SforcePartnerClient();
$client->createConnection($wsdl);
$loginResult = $client->login($username, $password.$key);
$sObject = new sObject();
$sObject->type = 'Leads';
$sObject->fields = $_POST;
$result = $client->update(array($sObject));
if ($result->success)
{
echo 'thank you for choosing our products, someone will contact you shortly';
}
else
{
$error = '<pre>' . print_r($result, true) . '</pre>';
mail('you@youremail.com', 'Lead update error', 'Something happend on the upate'. $error);
}
}
catch (exception $e)
{
// This is reached if there is a major problem in the data or with
// the salesforce.com connection. Normal data errors are caught by
// salesforce.com
echo '<pre>' . print_r($e, true) . '</pre>';
return false;
exit;
}
}
?>
You have clearly define your $_POST names and vales for the fields you want to update so they will match your salesforce field names:
example:
if you had a custom field in your leads object in salesforce called ContactMe__c, then the name in your field would be "ContactMe__c", such as:
Code:
<td>Yes<input type="radio" name="ContactMe__c" value="true" /></td>
<td>No<input type="radio" name="ContactMe__c" value=false" /></td>
<input type="hidden" name="leadid" value="<?php echo $_GET['leadid']; ?>" />
the <?php echo $_GET['leadid']; ?> is the ID like in your example > www.mywebsite.com/survey.php?leadid=xxxxxxxxx , this would be the ID of the of the lead record that you want to update in Salesforce, such as a06R0000003tXzgIAE
I hope this helps and let me know if this is what you are looking for!!
~Mike
Bookmarks