Hi,
I am a Joomla Developer and new to Saleforce. I am working on Fields Synchronization to setup a lead form dynamically in my website. I am trying to get the Field information like field name, field type etc used in my Salesforce Lead Module into my Joomla website. i.e when I click a button in my Joomla website all the Lead fields information from the Salesforce Crm database should store into my joomla database
Please let me know how can I get the Field information data with the help of Api or is there any other method available to get this done.
Please help me.
Thanks & Regards
Ameen
Last edited by ameen; 10-19-2010 at 10:25 AM.
So you have lead information that you want to get from Salesforce onto a page within Joomla. I am not that experienced with Joomla, but it should be pretty straight forward.
You need to download the salesforce php toolkit, which you can access from my menu on the front page.
Then you need to get that setup and make sure you can connect to salesforce's API from the server that you are trying to query.
Then some simple code:
PHP Code:<?php
//set this to make sure your not caching the WSDL
ini_set("soap.wsdl_cache_enabled", "0");
//make sure you change this to match your path to the partner client from the php tool kit
require_once ('./includes/soapclient/SforcePartnerClient.php');
//make sure you change this to match your path to the partner client from the php tool kit
$wsdl = './includes/soapclient/partner.wsdl.xml';
$userName = "username";
$password = "password";
$key = 'yourkey';
$password = $password . $key;
$lead_data = array();
//setup connection
$client = new SforcePartnerClient();
$client->createConnection($wsdl);
$loginResult = $client->login($userName,$password);
//SOQL query for Object in Salesforce change this to whatever you want to query
$soql = "Select Id, name FROM Lead";
$records = get_records($client, $soql);
foreach ($records as $r)
{
$lead_data['id'] = $r->Id;
$dwin_data['name'] = $r->fields->Name;
//use this to look at the data coming in
echo '<pre>' . print_r($r, true) . '</pre>';
}
//function to get records from Salesforce
function get_records(&$connection, &$query)
{
$queryOptions = new QueryOptions(2000);
$response = new QueryResult($connection->query($query));
// if the size is zero, where done
if ($response->size > 0)
{
$products = $response->records;
// Cycles through additional responses if the number of records
// exceeds the batch size
while (!$response->done)
{
set_time_limit(100);
$response = $connection->queryMore($response->queryLocator);
$products = array_merge($products, $response->records);
}
}
return $products;
}
?>
that should get you started
~Mike
Hi Mike,
Thank you very much for your prompt reply.
I have downloaded the phptoolkit and made the setup.
I just need to know which username, password and key I should give in the variables and also let me know where can I find the key ?
$userName = "username";
$password = "password";
$key = 'yourkey'
Thanks & Regards
Ameen
Last edited by ameen; 10-20-2010 at 12:39 AM.
Hi Mike,
Again Thanks for you help, I Managed to find the username, password and key to be used in Api. This is great. Now my connection is established with the salesforce.com.
Now what I need is the query to get the details for Fields used in my Salesforce.com Lead Form example Firstname, Lastname, CustomField1, CustomField2 and so on. I need to fetch the information of fields used in lead form like field name, field type and so on in order to generate those fields automatically and setting up a lead form in my website using those information.
If I use $soql = "Select Id, name FROM Lead"; it is fetching the submitted lead data.
I need the information to fields used in the lead form. So please help me with query to get these information.
Thanks & Regards
Ameen
Last edited by ameen; 10-20-2010 at 03:15 AM.
Hi Ameen,
It seems to me that you want to Dynamically get the Field Names of all fields for a SalesForce Object. In this case, it's the Lead Object.
Use the DescribeSObject. See this page for a sample of how to do this.
PHP Toolkit 13.0 DescribeSObject Sample (Partner) - developer.force.com
You might want to check out this page for joomla integration:
miiJoomla Salesforce To Website Intergration
A plug here of our Joomla/SalesForce Integration/Webforms you might be interested in:
miiJoomla - SalesForce App, Joomla Extension - Integration
Bookmarks