• emart
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Maybe someone can help me with this problem, I'm new to salesforce and this is driving me up the wall…

We have a site that we're moving over to salesforce to manage our customers when they buy from us.  We have an enterprise account, with Person Accounts enabled, and I have a script (from the salesforce API) that adds a new user to salesforce as a result of a new user signing up on our site.  That works very well.

I need to extend this to include:

1. I need to check to make sure the user isn't already there before adding them.
2. Add product purchase into the opportunity fields to be tracked.  For example, one contact may purchase multiple products, and we want to track them individually.
3. Potentially add referral information (partner id?) into the opportunity
4. Return the response from salesforce and put into local db for tracking.

On a basic level, the API script responds with the id of the user that was added, but have had a hard time doing anything with that (tried using array functions, etc.) other than printing to the screen with print_r.  I also don't know how to find out what products I need to reference for the transactions.

Any help that anyone can provide would be most appreciated. 

Here is the script I have now:

<?php
// SOAP_CLIENT_BASEDIR - folder that contains the PHP Toolkit and your WSDL
// $USERNAME - variable that contains your Salesforce.com username (must be in the form of an email)
// $PASSWORD - variable that contains your Salesforce.com password

define("SOAP_CLIENT_BASEDIR", "phptoolkit-13_1/soapclient");
require_once (SOAP_CLIENT_BASEDIR.'/SforceEnterpriseClient.php');
require_once ('phptoolkit-13_1/userAuth.php');
try {
  $mySforceConnection = new SforceEnterpriseClient();
  $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
  $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);

  $sObject = new stdClass();
  $sObject->FirstName = 'George';
  $sObject->LastName = 'Smith';
  $sObject->Phone = '510-555-5555';
  $sObject->PersonEmail = 'test@test.com';
  $sObject->BillingStreet = '12 E Walsh Dr';
  $sObject->BillingCity = 'Aurora';
  $sObject->BillingState = 'CO';
  $sObject->BillingPostalCode = '80234';
  $sObject->BillingCountry = 'US';
  $sObject->PersonMailingStreet = '12 E Walsh Dr';
  $sObject->PersonMailingCity = 'Aurora';
  $sObject->PersonMailingState = 'CO';
  $sObject->PersonMailingPostalCode = '80234';
  $sObject->PersonMailingCountry = 'US';

       
  $createResponse = $mySforceConnection->create(array($sObject), 'Account');
  print_r($createResponse);

} catch (Exception $e) {
  echo $mySforceConnection->getLastRequest();
  echo $e->faultstring;
}
?>
  • January 14, 2010
  • Like
  • 0
Maybe someone can help me with this problem, I'm new to salesforce and this is driving me up the wall…

We have a site that we're moving over to salesforce to manage our customers when they buy from us.  We have an enterprise account, with Person Accounts enabled, and I have a script (from the salesforce API) that adds a new user to salesforce as a result of a new user signing up on our site.  That works very well.

I need to extend this to include:

1. I need to check to make sure the user isn't already there before adding them.
2. Add product purchase into the opportunity fields to be tracked.  For example, one contact may purchase multiple products, and we want to track them individually.
3. Potentially add referral information (partner id?) into the opportunity
4. Return the response from salesforce and put into local db for tracking.

On a basic level, the API script responds with the id of the user that was added, but have had a hard time doing anything with that (tried using array functions, etc.) other than printing to the screen with print_r.  I also don't know how to find out what products I need to reference for the transactions.

Any help that anyone can provide would be most appreciated. 

Here is the script I have now:

<?php
// SOAP_CLIENT_BASEDIR - folder that contains the PHP Toolkit and your WSDL
// $USERNAME - variable that contains your Salesforce.com username (must be in the form of an email)
// $PASSWORD - variable that contains your Salesforce.com password

define("SOAP_CLIENT_BASEDIR", "phptoolkit-13_1/soapclient");
require_once (SOAP_CLIENT_BASEDIR.'/SforceEnterpriseClient.php');
require_once ('phptoolkit-13_1/userAuth.php');
try {
  $mySforceConnection = new SforceEnterpriseClient();
  $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
  $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);

  $sObject = new stdClass();
  $sObject->FirstName = 'George';
  $sObject->LastName = 'Smith';
  $sObject->Phone = '510-555-5555';
  $sObject->PersonEmail = 'test@test.com';
  $sObject->BillingStreet = '12 E Walsh Dr';
  $sObject->BillingCity = 'Aurora';
  $sObject->BillingState = 'CO';
  $sObject->BillingPostalCode = '80234';
  $sObject->BillingCountry = 'US';
  $sObject->PersonMailingStreet = '12 E Walsh Dr';
  $sObject->PersonMailingCity = 'Aurora';
  $sObject->PersonMailingState = 'CO';
  $sObject->PersonMailingPostalCode = '80234';
  $sObject->PersonMailingCountry = 'US';

       
  $createResponse = $mySforceConnection->create(array($sObject), 'Account');
  print_r($createResponse);

} catch (Exception $e) {
  echo $mySforceConnection->getLastRequest();
  echo $e->faultstring;
}
?>
  • January 14, 2010
  • Like
  • 0