Obama '08

               
   

Go Back   Mike Simonds > Salesforce > Salesforce PHP Tutorials

This is a discussion on Salesforce PHP script which lists all Objects and Fields within the Salesforce PHP Tutorials forums, part of the Salesforce category; Here is a small script that will iterate through all your Salesforce

Reply
 
LinkBack (11) Thread Tools Rate Thread
  #1  
Old 10-04-2007, 08:01 AM
Administrator
 
Join Date: May 2007
Posts: 246
Send a message via AIM to mike Send a message via MSN to mike Send a message via Yahoo to mike Send a message via Skype™ to mike
Salesforce PHP script which lists all Objects and Fields

Here is a small script that will iterate through all your Salesforce objects and return all the field or column names using PHP 5, the latest PHP toolkit, and the API. I am releasing this so if you want to take a look at all tables and fields, you can. There is nothing special about this script; it's just a handy little tool to view all objects with field names in Salesforce.

This script could help you when you are trying to build a set of scripts that will perform backups for MySQL, Oracle, or postgreSQL.

I hope that it helps people!


~Mike

make sure you check the paths for the Toolkit scripts, wsdl, and your salesforce login information



PHP Code:
<?php
error_reporting
(E_ERROR E_WARNING E_PARSE E_NOTICE);
require_once (
'./includes/soapclient/SforcePartnerClient.php');
require_once (
'./includes/soapclient/SforceHeaderOptions.php');

// full path name for the create tables file
try {
    
//salesforce login and wsdl
    
$wsdl './includes/soapclient/partner.wsdl.xml';
    
$userName "user@email.com";
    
$password "password";

    
//connect to salesforce
    
$client = new SforcePartnerClient();
    
$client->createConnection($wsdl);
    
$loginResult $client->login($userName$password);


    if (isset(
$client)) {
        
// Retrieve all the objects in the organization
        
$result $client->describeGlobal();

        
// Cycle through each object
        
foreach ($result->types as $objectType) {

            
// Retrieve the object definition
            
$resultObject $client->describeSObject($objectType);
            echo 
"<strong><u>" $objectType "</u></strong><br />\n";
            
// Cycle through each field
            
foreach ($resultObject->fields as $field) {
                echo 
$field->name "<br />";
            }
            echo 
'<hr />';

        }
    }


}
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($etrue) . '</pre>';
    return 
false;
    exit;
}
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

LinkBacks (?)
LinkBack to this Thread: http://www.mikesimonds.com/salesforce-php-script-which-lists-all-objects-and-fields-t56.html
Posted By For Type Date
Community - Re: Custom Formula field in SOQL query, describeSObject, PHP - Perl, PHP, Python & Ruby Development - Salesforce.com Community This thread Refback 08-12-2008 06:54 PM
Community - Custom Formula field in SOQL query, describeSObject, PHP - Perl, PHP, Python & Ruby Development - Salesforce.com Community This thread Refback 02-11-2008 07:11 AM
Community - how do I pull single field from describeSObject? - Perl, PHP, Python & Ruby Development - Salesforce.com Community This thread Refback 01-15-2008 10:40 PM
Community - Re: how do I pull single field from describeSObject? - Perl, PHP, Python & Ruby Development - Salesforce.com Community This thread Refback 01-08-2008 09:19 PM
Re: how do I pull single field from describeSObject? - Perl, PHP, Python & Ruby Development This thread Refback 01-08-2008 08:04 PM
Community - how do I pull single field from describeSObject? - Perl, PHP, Python & Ruby Development - Salesforce.com Community This thread Refback 01-04-2008 05:56 PM
Community - how do I pull single field from describeSObject? - Perl, PHP, Python & Ruby Development - Salesforce.com Community This thread Refback 01-03-2008 06:44 AM
Community - Re: Custom Formula field in SOQL query, describeSObject, PHP - Perl, PHP, Python & Ruby Development - Salesforce.com Community This thread Refback 10-08-2007 05:42 AM
Community - Custom Formula field in SOQL query, describeSObject, PHP - Perl, PHP, Python & Ruby Development - Salesforce.com Community This thread Refback 10-07-2007 07:51 PM
Community - Re: Custom Formula field in SOQL query, describeSObject, PHP - Perl, PHP, Python & Ruby Development - Salesforce.com Community This thread Refback 10-04-2007 11:12 AM
Community - Custom Formula field in SOQL query, describeSObject, PHP - Perl, PHP, Python & Ruby Development - Salesforce.com Community This thread Refback 10-04-2007 09:36 AM



Powered by vBulletin


SEO by vBSEO 3.2.0 RC8 ©2008, Crawlability, Inc.

1 2 3 4 5