WWW::Salesforce - this class provides a simple abstraction layer between SOAP::Lite and Salesforce.com.
use WWW::Salesforce; my $sforce = eval { WWW::Salesforce->login( username => 'foo', password => 'bar' ); }; die "Could not login to SFDC: $@" if $@; # eval, eval, eval. WWW::Salesforce uses a SOAP connection to # salesforce.com, so things can go wrong unexpectedly. Be prepared # by eval'ing and handling any exceptions that occur.
This class provides a simple abstraction layer between SOAP::Lite and Salesforce.com. Because SOAP::Lite does not support complexTypes, and document/literal encoding is limited, this module works around those limitations and provides a more intuitive interface a developer can interact with.
The login method returns an object of type WWW::Salesforce if the login attempt was successful, and 0 otherwise. Upon a successful login, the sessionId is saved and the serverUrl set properly so that developers need not worry about setting these values manually. Upon failure, the method dies with an error string.
login
The following are the accepted input parameters:
A Salesforce.com username.
The password for the user indicated by username.
username
The convertLead method returns an object of type SOAP::SOM if the login attempt was successful, and 0 otherwise.
convertLead
leadId => [ 2345, 5678, ], contactId => [ 9876, ],
Adds one new individual objects to your organization's data. This takes as input a HASH containing the fields (the keys of the hash) and the values of the record you wish to add to your organization. The hash must contain the 'type' key in order to identify the type of the record to add.
Returns a SOAP::Lite object. Success of this operation can be gleaned from the envelope result.
$r->envelope->{Body}->{createResponse}->{result}->{success};
Deletes one or more individual objects from your organization's data. This subroutine takes as input an array of SCALAR values, where each SCALAR is an sObjectId.
Executes a query against the specified object and returns data that matches the specified criteria.
The query string to use for the query. The query string takes the form of a basic SQL statement. For example, "SELECT Id,Name FROM Account".
This sets the batch size, or size of the result returned. This is helpful in producing paginated results, or fetch small sets of data at a time.
Executes a query against the specified object and returns data that matches the specified criteria including archived and deleted objects.
Retrieves the next batch of objects from a query or queryAll.
query
queryAll
The handle or string returned by query. This identifies the result set and cursor for fetching the next set of rows from a result set.
Updates one or more existing objects in your organization's data. This subroutine takes as input a type value which names the type of object to update (e.g. Account, User) and one or more perl HASH references containing the fields (the keys of the hash) and the values of the record that will be updated.
The hash must contain the 'Id' key in order to identify the record to update.
Updates or inserts one or more objects in your organization's data. If the data doesn't exist on Salesforce, it will be inserted. If it already exists it will be updated.
This subroutine takes as input a type value which names the type of object to update (e.g. Account, User). It also takes a key value which specifies the unique key Salesforce should use to determine if it needs to update or insert. If key is not given it will default to 'Id' which is Salesforces own internal unique ID. This key can be any of Salesforces default fields or an custom field marked as an external key.
Finally, this method takes one or more perl HASH references containing the fields (the keys of the hash) and the values of the record that will be updated.
Retrieves the current system timestamp (GMT) from the sforce Web service.
Retrieves personal information for the user associated with the current session.
A user ID
Retrieves the list of individual objects that have been updated (added or changed) within the given timespan for the specified object.
Identifies the type of the object you wish to find updates for.
A string identifying the start date/time for the query
A string identifying the end date/time for the query
Retrieves the list of individual objects that have been deleted within the given timespan for the specified object.
Identifies the type of the object you wish to find deletions for.
Describes metadata (field list and object properties) for the specified object.
The type of the object you wish to have described.
Describes metadata about a given page layout, including layouts for edit and display-only views and record type mappings.
Retrieves a list of available objects for your organization's data.
Sets the specified user's password to the specified value.
A user Id.
The new password to assign to the user identified by userId.
userId
Changes a user's password to a server-generated value.
A comma delimited list of field name you want retrieved.
The type of the object being queried.
The ids (LIST) of the object you want returned.
The search string to be used in the query. For example, "find {4159017000} in phone fields returning contact(id, phone, firstname, lastname), lead(id, phone, firstname, lastname), account(id, phone, name)"
Returns a hash with information about errors from API calls - only useful if ($res->valueof('//success') ne 'true')
{ 'statusCode' => 'INVALID_FIELD_FOR_INSERT_UPDATE', 'message' => 'Account: bad field names on insert/update call: type' ... }
use WWW::Salesforce; my $sf = WWW::Salesforce->login( 'username' => $user,'password' => $pass ) or die $@;
my $query = 'find {4159017000} in phone fields returning contact(id, phone, '; $query .= 'firstname, lastname), lead(id, phone, firstname, lastname), '; $query .= 'account(id, phone, name)'; my $result = $sforce->search( 'searchString' => $query );
Please visit Salesforce.com's user/developer forums online for assistance with this module. You are free to contact the author directly if you are unable to resolve your issue online.
The describeSObjects and describeTabs API calls are not yet complete. These will be completed in future releases.
describeSObjects
describeTabs
Not enough test cases built into the install yet. More to be added.
L<DBD::Salesforce> by Jun Shimizu L<SOAP::Lite> by Byrne Reese Examples on Salesforce website: L<http://www.sforce.com/us/docs/sforce70/wwhelp/wwhimpl/js/html/wwhelp.htm>
This Perl module was originally provided and presented as part of the first Salesforce.com dreamForce conference on Nov. 11, 2003 in San Francisco.
Fred Moyer <fred at redhotpenguin dot com>
Thanks to:
Chase Whitener <cwhitener at gmail dot com> - Maintaining this module and working on development version.
Michael Blanco - Finding and fixing some bugs.
Garth Webb - Finding and fixing bugs. Adding some additional features and more constant types.
Ron Hess - Finding and fixing bugs. Adding some additional features. Adding more tests to the build. Providing a lot of other help.
Tony Stubblebine - Finding a bug and providing a fix.
Jun Shimizu - Providing more to the WWW::Salesforce::Constants module and submitting fixes for various other bugs.
Byrne Reese - <byrne at majordojo dot com> - Byrne Reese wrote the original Salesforce module.
Copyright 2010 Fred Moyer, All rights reserved.
Copyright 2005-2007 Chase Whitener.
Copyright 2003-2004 Byrne Reese, Chase Whitener. All rights reserved.
This library is free software and may be distributed under the same terms as perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
'=item' outside of any '=over'
To install WWW::Salesforce, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::Salesforce
CPAN shell
perl -MCPAN -e shell install WWW::Salesforce
For more information on module installation, please visit the detailed CPAN module installation guide.