Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Perl, PHP, Python & Ruby Development
- :
- Using php Toolkit to add new record
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Using php Toolkit to add new record
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-12-2012 04:32 AM
I've used the toolkit for several applications to read data - but never to insert or update. So I'm happy that the connection code and the WSDL are ok.
I'm trying to replicate the sample code PHP Toolkit 20.0 Upsert Sample (Enterprise) to insert a new contact record before tying something more adventurous !
<?php
define("USERNAME", "XXXXXXX");
define("PASSWORD", "YYYY");
define("SECURITY_TOKEN", "ZZZZZZZZZZZZZZZZZZZZ");
require_once ('soapclient/SforceEnterpriseClient.php');
require_once ('userAuth.php');
try {
$mySforceConnection = new SforceEnterpriseClient();
$mySforceConnection->createConnection("soapclient/ enterprise.wsdl.xml");
$mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);
$sObject = new stdClass();
$sObject->FirstName = 'George';
$sObject->LastName = 'Smith';
$sObject->Phone = '512-555-555';
$sObject->BirthDate = '1927-01-25';
$sObject->Email = 'test@example.com';
$createResponse = $this->$mySforceConnection->create(array($sObject) ,'Contact');
echo "Creating new contact \r\n";
print_r($createResponse);
} catch(Exception $e) {
echo $mySforceConnection->getLastRequest();
echo $e->faultstring;
}
?>
The above code fails without any error message - presumably it fails to compile, although it passes my .php editor's checks. I've changed the line
$createResponse = $this->_$mySforceConnection->create(array($sObject
to
$createResponse = $this->$mySforceConnection->create(array($sObject)
Can anyone suggest what might be wrong with this code ?
Thanks.
Solved! Go to Solution.
Re: Using php Toolkit to add new record
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-13-2012 08:07 PM
You shouldn't need $this in front of $mySforceConnection. Try using
$createResponse = $mySforceConnection>create(array($sObject),'Contact');
Salesforce.com Certified Developer
Re: Using php Toolkit to add new record
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-14-2012 12:48 AM
Brilliant - thanks very much. I'm off to brush up my php OOP to work out why this-> was wrong !
Thanks again.
Peter
Re: Using php Toolkit to add new record
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-27-2013 11:21 PM
HI,
You can find the Basic Tutorials about PHP and Salesforce Implementation using Below URL
http://theblogreaders.com/integration-between-sale
TheBlogreaders.com
Blog | Salesforce Certified Administrator | Salesforce Certified Developer
Re: Using php Toolkit to add new record
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-26-2013 04:58 AM
HI,
You can find the Basic Tutorials about PHP and Salesforce Implementation using Below URL
http://theblogreaders.com/integration-between-sale
TheBlogreaders.com
Blog | Salesforce Certified Administrator | Salesforce Certified Developer

