Extension:Salesforce

What can this extension do?
Configure MediaWiki to allow users the ability to access Saleforce.com. Very useful for admins looking to document customizations or for anyone looking to make Salesforce data available though a public interface. Recommended for Intranet usage; see Extension:LDAP Authentication for a way to limit users via LDAP/Active Directory.

Describe
Using simple markup tags, users can list all the fields available in a specified standard or custom object. Useful for administrators wanting to quickly build documentation for Saleforce users creating reports.

Query
Enable wiki users to query records in Salesforce by entering their own SOQL syntax query statement. Query function handles multiple custom and standard objects.

Download instructions
Download salesforce.zip (42.2 kb)

Installing the Extension
Download the installer file to the Extensions directory of your MediaWiki installation. Uncompress the file using Winzip or a similar application using the exisiting file structure. This should extract the following files;
 * extensions\Salesforce
 * extensions\Salesforce\index.php
 * extensions\Salesforce\soapclient
 * extensions\Salesforce\soapclient\enterprise.wsdl.xml
 * extensions\Salesforce\soapclient\partner.wsdl.xml
 * extensions\Salesforce\soapclient\SforceBaseClient.php
 * extensions\Salesforce\soapclient\SforceEnterpriseClient.php
 * extensions\Salesforce\soapclient\SforceHeaderOptions.php
 * extensions\Salesforce\soapclient\SforcePartnerClient.php

This extension makes use of version 1.1 of Salesforce's PHP Toolkit. The installation file already includes the required files so the tool kit does not need to be installed separately.

Required PHP Extensions
In order to use the HTTPS protocol you need to enable some of the PHP extensions. Open PHP.ini for editing. Search for "extension=php_curl.dll". There should be a semi-colon in front of that line - remove it to enable the extension. Scroll down and find "extension=php_openssl.dll" and do the same. Now scroll down a bit further and find "extension=php_sockets.dll". Leave this line alone, but insert a new line below it and type "extension=php_soap.dll" on that line. For some reason, this entry doesn't appear in the default configuration. Save the file and exit.

SSL Library Files
Windows Users: Copy the SSL library files from the PHP installation directory to your Windows system directory. The two files are libeay32.dll and ssleay32.dll. They need to be copied into the system directory, usually c:\windows\system32 on an XP system. If you happen to have OpenSSL already installed on your computer you may find that these files are already installed. If they are, you should only replace them if the ones from the PHP directory are more recent. Change the extensions on the existing ones by adding '.bak' just to be safe.

Modify LocalSettings.php
To install this extension, add the following to LocalSettings.php:

Configuration parameters

 * $wgSFDC_user = "username@salesforce.com"; //Salesforce user id
 * $wgSFDC_pword = "password"; //Salesforce password
 * $wgSFDC_allow_qry = false; //allow users to define queries, default is false
 * $wgSFDC_allow_desc = false; //allow users to describe objects, default is false
 * $wgSFDC_qry_max_rows = 10; //for query - sets max number of records returns, overrides LIMIT in query statement

Usage
This tag extension uses a simple markup language in the following format.

Allowable actions are query and describe.

Describe
Lists the names, api labels, and descriptive info of fields for a given standard or custom object.

Features
Any objects referenced in relationship fields are displayed an internal link. For documentation, you can create pages describing all custom and standard objects.

Picklist and multipicklist values are listed.

Example
Describing a standard object.

Describing a custom object (Job Posting). Note the "__c" suffix.

Query
Using this extension, users can retrieve records from Salesforce by entering a query in Salesforce Object Query Language (SOQL) syntax. For more details on SOQL and writing proper SELECT statements see http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select.htm.

Examples
Querying a single standard object.

Querying two standard objects (Contact and Account) using a reference field (Account.Name).

Querying two standard objects (Contact and Account) using dotted notation.

Querying a custom and standard object (Job Posting and Account) using dotted notation. In this example, the Job Posting custom object has a field called Employer which reference the Account object.

Querying a custom object and two standard objects (Application, Contact, and Account) using dotted notation. In this example, the Application custom object has a fields called Contact and Account which reference the Contact and Account objects respectively.

Select
The SOQL SELECT command uses the following syntax:

SELECT fieldList FROM objectType [WHERE The Condition Expression (WHERE Clause)] [ORDER BY] LIMIT ?

For more details on SOQL and writing proper SELECT statements see http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select.htm.

Columns
Specify the header labels for the columns separated by commas. Column headers are printed in the order they are specified exactly as written. Column values are displayed in the order they appear in the query string.

For example,  will output;

Changing the order of the columns specified does not affect the order of the values outputted, only the headers.

To change the order of the values, change the order those fields appear in the Select statement. For example;

NOTE:
 * The ID field will always appear in the first column. This is a limitation in the way the Salesforce API Describe call handles the ID field. It may be corrected in later versions.
 * Fields for the base object will always be outputted prior to fields of referenced objects regardless of the order in which they appear in the Select statement. So that  will display as


 * The number of column headers should match the number of fields specified in the select statement. Mismatches will result in tables with missing column headers.

will display as

To leave a column header blank use an empty string such as

Please Note:
 * Column names cannot include commas
 * At least one column name is required.
 * Remember to use "__c" suffix when referencing custom objects and fields.

Troubleshooting
Since this is an early release of this extension, I would appreciate any and all assistance in testing. Please not your issues on the Discussion page.

Please use a tool like the APEX toolkit for Eclipse or Salesforce's Apex Explorer to test and verify your SOQL statement before posting it as an issue.

Known issues
I'm currently working on addressing these items for the stable release
 * $wgSFDC_allow_qry and $wgSFDC_allow_desc do not restict access as expected.
 * Queries are not dynamic. Results are not updated when page is viewed only when edited.

To Do

 * Figure out a way to get values of referenced object to output in exactly the same order as specified in the select statement
 * Limit the maximum number of records at the time of the API call for faster processing.
 * Add options for defining table colors.