Skip to Content

TheBlogReaders.com

Salesforce.com, PHP, MySQL, Javascript, Ajax, Htacces

How to Create New Salesforce Custom Object Using PHP Script

Be First!
by February 26, 2013 PHP, SALESFORCE

How to Create New Salesforce Custom Object Using PHP Script

We can creates custom object in salesforce using PHP Script.


<?php
require_once('soapclient/SforcePartnerClient.php');
require_once('soapclient/SforceMetadataClient.php');
try {
$mySforceConnection = new SforcePartnerClient();
$mySoapClient = $mySforceConnection->createConnection('soapclient/Partnetwsdl.xml');
$loginResult = $mySforceConnection->login('xxxx@xx.com', 'cc20127B8fw0x92YerGiV4zak5ucMc');
$myMetadataConnection = new SforceMetadataClient('soapclient./metadata.xml', $loginResult, $mySforceConnection);

//Create object
$customObject = new SforceCustomObject();
$customObject->fullName = 'CustomObjFromPHP__c';
$customObject->deploymentStatus = DEPLOYMENT_STATUS_DEPLOYED;

$customObject->setDescription("A description");
$customObject->setEnableActivities(true);
$customObject->setEnableDivisions(false);
$customObject->setEnableHistory(true);
$customObject->setEnableReports(true);
$customObject->setHousehold(false);
$customObject->setLabel("My Custom Obj from PHP");
$customField = new SforceCustomField();
$customField->setFullName('MyCustomFieldb__c');
$customField->setDescription('Description of New Field');
$customField->setLabel('My Custom Field Label');
$customField->setType('Text');

$customObject->nameField = $customField;

$customObject->pluralLabel = 'My Custom Objs from PHP';
$customObject->sharingModel = SHARING_MODEL_READWRITE;
print_r($myMetadataConnection->create($customObject));

} catch (Exception $e) {
echo $myMetadataConnection->getLastRequest();
echo $e->faultstring;
}

?>

You can find the Basic Tutorials about PHP and Salesforce Implementation using Below URL

http://theblogreaders.com/integration-between-salesforce-and-php

(827)

Previous
Next

Leave a Reply