• Park Walker (TAGL)
  • SMARTIE
  • 525 Points
  • Member since 2005
  • President and CEO
  • The Ashland Group, Ltd.

  • Chatter
    Feed
  • 20
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 259
    Replies

The person who set this up is no longer with the company.  I need to programatically query/extract some info from SalesForce so I can backload into Oracle or MySql  (so to csv).   

Trying to use a semi-join to filter out some Contacts to reduce rows of data.  Filter the contacts Id to a list of values from custom field in a custom object (should be so simple.... ) 

Get error about teh semi-join not being valid in current version. 

How do I identify the version installed and more importantly how can I fix this?  

(btw all relationships are 'lookups'  so i'm not having too much luck with selecting combined object info.. have to exort each object indifividually) 

 

Thank you.  

here's what I've found...  

 

WWW::Salesforce::Simple

my $sf = WWW::Salesforce::Simple->new( username => $sf_id, password => $sf_pw );

my $query ="Select Id, AccountId, LastName, FirstName, Salutation, Name, Email, Title, OwnerId FROM Contact WHERE Id IN (SELECT Channel_Partner_Manager__c FROM Office_Profile__c WHERE Lead_Source__c = 'Channel Partner' and Source_Detail__c = 'xxx123')";

my $res = $sf->do_query( $query );

UNSUPPORTED_API_VERSION:

Title, OwnerId FROM Contact WHERE Id IN (SELECT Channel_Partner_Manager__c

^

ERROR at Row:1:Column:157

Semi joins are not supported in this version of the API at ./force-get-test.pl line 127

Can't call method "fault" without a package or object reference at

/usr/lib/perl5/site_perl/5.8.8/WWW/Salesforce/Simple.pm line 42 (#4)

(F) You used the syntax of a method call, but the slot filled by the

object reference or package name contains an expression that returns a

defined value which is neither an object reference nor a package name.

Something like this will reproduce the error:

 

$BADREF = 42;

process $BADREF 1,2,3;

$BADREF->process(1,2,3);

 

Uncaught exception from user code:

Can't call method "fault" without a package or object reference at /usr/lib/perl5/site_perl/5.8.8/WWW/Salesforce/Simple.pm line 42.

at /usr/lib/perl5/site_perl/5.8.8/WWW/Salesforce/Simple.pm line 42

WWW::Salesforce::Simple::do_query('WWW::Salesforce::Simple=HASH(0x9b2e1ec)', 'Select Id, AccountId, LastName, Fi...') called at

 

 

 

date of the Simple.pm is from 2009 although it looks like this directory tree was updated in April...  

 

Thank you. 

 

Hi everyone.

 

I'm new to Salesforce Toolkit 20.  Looking for info on accessing Custom fields in custom objects.

 

Query works fine in Force.com explorer and in PHP script, but output is not showing field names.  I've updated the enterprise.wdsl.xml file and clearly see the Correct custom field info in the xml file, but query looks like this:

 

$query = "Select Id, NameInfo__c, data__c from customobject"

 

and output looks like this:

 

SObject Object

(  

 [type] =>    

 [fields] =>    

  [Id] => a1eE0000000LABcIAO

)

 

SObject Object

(

[type] =>    

[fields] =>    

[Id] => a1eE0000000LABdIAO

)

 

SObject Object

(    

[type] =>    

[fields] =>    

[Id] => a1eE0000000LABeIAO

)

 

The ID can be printed with $record->ID.  How do I reference the custom fields?  Any attempt ends with "Undefined property: SObject::$NameInfo or   ...NameInfo__c     

 

Any suggestions or recommendations for where to look next?

Using the PHP API code...

$theQuery = "Select s.TranscriptGrade__c, s.SystemModstamp, s.StudentID__c, 
            s.StudentCourseID__c, s.SignatureGrade__c, s.ReceiptNumber__c, s.Project_ID__c, 
            s.OwnerId, s.Name, s.Multi_Class_Project_id__c, s.LastModifiedDate, s.LastModifiedById, 
            s.IsDeleted, s.Id, s.GradeDate__c, s.EvalPosted__c, s.CreditStatus__c, s.CreatedDate, 
            s.CreatedById, s.ClientID__c From STUDENT_COURSE__c s Where s.ClientID__c='" . $theContactID . "'";
 
$result = $theSFConnection->query($theQuery); 

I am getting the error:

Unexpected exception of type [SoapFault] with message [INVALID_TYPE: 
s.CreatedById, s.ClientID__c From STUDENT_COURSE__C s Where s.ClientID__c=''
                                  ^
ERROR at Row:5:Column:47
sObject type 'STUDENT_COURSE__C' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names

Tried the same call using the Java Eclipse schema tool and the query succeeds so there seems to be an issue with the PHP API.  We are developing our application with the requirement of using PHP so we would like to figure out a work around to this issue.

Thanks,
-Laura 

Hello,

 

I am trying to capture an email address with a form and then search for it in saelsforce and if it exists I will convert the lead. I can convert the lead via API but I can't seem to lookup by a form value, like $emailx. All I have to go on is

 

$result = $crmHandle->search('FIND {Joe Moke} IN Name Fields RETURNING Lead(Name, Phone)');



Which doesn't seem to work. There's isn't much PHP salesforce API help that I have found,

 

Any help would be appreciated.

I posted a similar question on the VisualForce board a few weeks ago without response, so I'm trying here.

 

I'm building a database on database.com that I want anyone to have Create and Read access to without registration, and Update and Delete with registration and apporopiate account ownership.  I've spent the last three months teaching myself APEX and VF, so when the database.com guys say, "The best part is, you can use anything you want to build the front end!", I want to use APEX and VF!

 

It's like when someone is "let go" from their job and says , "No you don't have to let me, I wasn't trying to go anyway.".

 

Can I use VF and APEX to build a database.com front end?  If not, would it be more efficient to learn more PHP rather than starting yet another language from scratch?  Is there a language that people feel strongly is vastly superior to PHP for database driven development and apps, perhaps including mobile somewhere down the road?

 

How does the Force.com IDE fit into this picture?

 

Thank you in advance.

Hello,

 

I have a custom object called "Notepad" associated with Accounts. There can be many notepads for one account (1:n). I am wonding, using php, what is the best way to select all the "Notepads" associated with a certain account based on the Account ID. 

 

Example:

 

I have the account Peter Test.

 

I create two Notepads associated with Peter Test.

 

The notepads contain a field labeled "internet_Provider".

 

From PHP I want to select the Peter Test's Account.FirstName Account.LastName and both Notepads.Internet_Provider, knowing only the Account ID.

 

I am able to select the FirstName and LastName no problem, but am unsure how to go about getting the custom objects and their contents.

 

Appreciate any help,

-Peter

 

 

I can't figure out a "clean" way to assign a RecordType when creating a new Account object.  Is it possible to do some kind of subquery during the create operation that will lookup the RecordTypeId based on the RecordType Name?

 

It just seems weird to me to have these 15 character Ids hard coded...

 

 

$so = new SObject();
$so->type = 'Account';
$so->fields = array(
  'Name' => $someName,
  'Phone' => $someNumber,
  'RecordTypeId' => '01270000000DVD5');

 

Maybe I'm missing something, but it would make more sense if it could be something like "RecordType.Name => Something" instead.

 

Hi everybody,

 

I have a problem while trying to login Salesforce, using the PHP API.

Here is the code i'm using :

 

 

define('SALESFORCE_USER', 'XXX');
define('SALESFORCE_PASS', 'XXX');
define('SALESFORCE_TOKEN', 'XXX');
define('SALESFORCE_WSDL', "XXX.wsdl");

require_once ('soapclient/SforceEnterpriseClient.php');
ini_set('soap.wsdl_cache_enabled', 0);
$crmHandle = new SforceEnterpriseClient();
try {
  $crmHandle->createConnection(SALESFORCE_WSDL);
} catch (Exception $e) {}

try {
  $crmHandle->login(SALESFORCE_USER, SALESFORCE_PASS . SALESFORCE_TOKEN);
} catch (Exception $e) {
  echo $e;
}

 

 

 

And i get the following error message :

 

SoapFault exception: [INVALID_LOGIN] INVALID_LOGIN: Invalid username, password, security token; or user locked out. in soapclient\SforceBaseClient.php:155 Stack trace: #0 [internal function]: SoapClient->__call('login', Array) #1 soapclient\SforceBaseClient.php(155): SoapClient->login(Array) #2 connect.php(33): SforceBaseClient->login('XXX', 'XXX') #3 {main}

 

Just one more information, i'm working on a sandbox,

maybe is it a reason to my problem ?

 

Any ideas about it ?

I'm a beginner with that and I need your help...

Thanks in advance

  • July 19, 2010
  • Like
  • 0

Hi,

 

We are developing a website in php and want to send data into sales force upon a successful transaction.

 

Does anyone know how I can find out what API functions are available?

 

Thanks in advance.

 

Denise

I've never used SalesForce before so I'm sorry if this is a stupid question but looking through the wiki only made me even more confused so I figured I'd ask here.

 

My client has a secure area on his website, where users can apply for access and their data is stored in a MySQL db on his server. When an admin goes in the back-end and enables access for this applicant, their data also needs to be sent to SalesForce so that the client can send them email updates, newsletters and so on. I'm not sure how to set this up as there seems to be many different ways/places in which data can be inserted. Looking for any help I can get... sample code would be awesome.

I can login to production just fine with my code.  But when I switch the wsdl to the sandbox one (the only change I make to my code), I get the following:

 

INVALID_LOGIN: Invalid username, password, security token; or user locked out.
Fatal error: SoapClient::__setSoapHeaders() [<a href='soapclient.--setsoapheaders'>soapclient.--setsoapheaders</a>]: Invalid SOAP header in C:\xampp\htdocs\SFApp\Includes\soapclient\SforceBaseClient.php on line 273

I do have the ini_set("soap.wsdl_cache_enabled", "0" ) ; line in my code.

 

 

What's going on?  Do I need to get a new security token for the sandbox?

 

Message Edited by skettios on 03-24-2010 03:49 PM

I am just starting out developing to this API.  I have php code that is not returning the same result and the IDE query when a custom field is in the statment.

 

 

<?php define("SOAP_CLIENT_BASEDIR", "soapclient"); require_once (SOAP_CLIENT_BASEDIR.'/SforceEnterpriseClient.php'); require_once (SOAP_CLIENT_BASEDIR.'/SforceHeaderOptions.php'); require_once (SOAP_CLIENT_BASEDIR.'/function.php'); require_once ('userAuth.php'); try { $mySforceConnection = new SforceEnterpriseClient(); $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl'); $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD); $query = "Select Name, CID__c, BillingCity, Account_Executive__c From Account a limit 20"; $something = "SELECT OwnerId Owner.Alias FROM Lead limit 1"; $createResponse = $mySforceConnection->query($query); echo "<table border=1 cellpadding=2>"; echo "<tr>"; echo "<th> Name </th>"; echo "<th> CID </th>"; echo "<th> City </th>"; echo "<th> Account Executive </th>"; echo "</tr>"; foreach ($createResponse as $createResult){ //print_r($createResult); //print("<br>"); for ($i=0, $num_result=count($createResult); $i < $num_result; $i++){ echo "<tr>"; echo "<td>"; print($createResult[$i]-> Name); echo "</td>"; echo "<td>"; print($creatResult[$i]-> CID__c ); echo "</td>"; echo "<td>"; print($createResult[$i]-> BillingCity ); echo "</td>"; echo "<td>"; print( $createResult[$i]-> Account_Executive__c ); echo "</td>"; echo "</tr"; } } echo "<table border=\"1\">"; } catch (Exception $e) { echo $mySforceConnection->getLastRequest(); echo "</br>"; echo "<h1>faultstring:</h1> </br>"; echo $e->faultstring; echo "</br>"; return $return; } ?>

 

The Custom fields come out blank.  However when I run the same SOQL query in Eclipse I get the records for the custom fields.  Am I doing this correctly?  I have read about cached data could this be my problem?

 

 

 

  • March 10, 2010
  • Like
  • 0

I am having trouble directly setting the Email field in my upsert.  I have custom fields which are also have a type of "email". (np01__home_email__c,  np01__alternateemail__c).   The Email field takes the value of the last custom email field I set in the upsert even if i specifically set Email.  

 

$sObject->fields['npe01__AlternateEmail__c'] = htmlspecialchars(stripslashes(strip_tags($row['email'])));

$sObject->fields['npe01__HomeEmail__c'] = 'test@test.com';

$sObject->fields['Email'] = htmlspecialchars(stripslashes(strip_tags($row['email'])));

$sObject->Email = htmlspecialchars(stripslashes(strip_tags($row['email']))); 

 

 

When i upsert that object, the Email field ends up as 'test@test.com'.   As you can see, I tried to set ->fields['Email'], as well as ->Email to no avail.  

 

Can anyone see anything wrong with what I am doing? 

Hi,

 

I'm trying to pull out the values from a query (just pulling 1 id,name in this case); it works fine when I print the full result, but when I try to get each one it doesnt work.

 

 

 

$queryResult = $mySforceConnection->query($query); $records = $queryResult->records; foreach ($records as $record) { $record = new SObject($record); $_id = $record->Id; $_name = $record->fields->Name; echo $_id; echo $_name; } foreach ($records as $record) { print_r($record); }

 

 it outputs:

 


Notice: Trying to get property of non-object in /srv/home-www/salesforce/test.php on line 50


0

 

SObject Object ( [type] => Account [fields] => stdClass Object ( [Name] => TheStreet.com Inc ) [Id] => 0018000000ZIXKWAA5 ) 

 

 

Any ideas?  Looked around and saw about 10 different ways to grab the info but none of them worked.  Thanks!

 

Casey

 

Hi,

 

I am fairly new using PHP with Salesforce, I have successfully created several query calls and gotten results back, but now I want to update a contact but the code is failing.  I have compared my code to several examples and can find no problems, but it still doesn't work.  Here is the code:

 

 

$mySforceConnection = new SforceEnterpriseClient(); $mySoapClient = $mySforceConnection->createConnection($wsdl); $mylogin = $mySforceConnection->login($username, $password); $sObject1->fields = array('FirstName' => 'Josh'); $sObject1->type = 'Contact'; $sObject1->Id = '00330000004dBxw'; $response = $mySforceConnection->update(array($sObject1));

 

 

The error message I get is this:

 

PHP Warning:  Missing argument 2 for SforceEnterpriseClient::update(), called in C:\inetpub\wwwroot\account.php on line 21 and defined in C:\inetpub\wwwroot\system\soapclient\SforceEnterpriseClient.php on line 68
PHP Notice:  Undefined variable: type in C:\inetpub\wwwroot\system\soapclient\SforceEnterpriseClient.php on line 70
PHP Fatal error:  Uncaught SoapFault exception: [sf:INVALID_TYPE] INVALID_TYPE: Must send a concrete entity type. in C:\inetpub\wwwroot\system\soapclient\SforceBaseClient.php:414
Stack trace:
#0 [internal function]: SoapClient->__call('update', Array)
#1 C:\inetpub\wwwroot\system\soapclient\SforceBaseClient.php(414): SoapClient->update(Object(stdClass))
#2 C:\inetpub\wwwroot\system\soapclient\SforceEnterpriseClient.php(73): SforceBaseClient->_update(Object(stdClass))
#3 C:\inetpub\wwwroot\account.php(21): SforceEnterpriseClient->update(Array)
#4 {main}
  thrown in C:\inetpub\wwwroot\system\soapclient\SforceBaseClient.php on line 414

 

As you can see I've made the code pretty simple to eliminate possible problem points.  The core error seems to be "INVALID_TYPE: Must send a concrete entity type"  Anyone have any ideas?

 

I am using PHP 5.3.0 with the PHP 13.0 Toolkit.

  • September 09, 2009
  • Like
  • 0

Hi,

 

I am new to php integration with salesforce. I have downloaded phptoolkit13.0 And I am trying to implement a sample provided on the website. I am facing a problem that when I run the page an error come

 


Fatal error: Class 'SoapClient' not found in C:\phpToolKit\soapclient\SforceBaseClient.php on line 121

 

I downloaded nuSoapClient package and it contains different classes.

 

Can someone tell me how to integrate the nusoapclient package in to toolkit?

 

Thanks 

  • August 03, 2009
  • Like
  • 0

I'm having an issue with 'fieldsToNull' and PHP Toolkit 13. I can't pass through an array of field names without getting this error:

 

$sObject->fieldsToNull = array('Current_Projects__c', 'About_Me__c');

 

Unexpected element {http://www.w3.org/2001/XMLSchema}string during simple type deserialization

 

Though, if I do:

 

$sObject->fieldsToNull = 'Current_Projects__c';

 

This will work fine, and set the field to null. But doesn't solve my problem of being able to set multiple field values to null.

 

Has anyone encountered this issue before?

Message Edited by David_FB on 03-10-2009 04:45 AM
Hi,

I've got an exception trying to upsert on a custom object with php toolkit 13:

Code:
SoapFault exception: [sf:INVALID_FIELD] INVALID_FIELD: No such column 'Comment__c' on entity 'contact'. in C:\Dev\Workspace\CnV\phptoolkit-13_0\soapclient\SforceBaseClient.php:419

Stack trace:

#0 [internal function]: SoapClient->__call('upsert', Array)

#1 C:\Dev\Workspace\CnV\phptoolkit-13_0\soapclient\SforceBaseClient.php(419): SoapClient->upsert(Object(stdClass))

#2 C:\Dev\Workspace\CnV\phptoolkit-13_0\soapclient\SforceEnterpriseClient.php(93): SforceBaseClient->_upsert(Object(stdClass))

#3 C:\Dev\Workspace\CnV\post.php(34): SforceEnterpriseClient->upsert('Comment__c', Array)

#4 {main}

 
I usually use update function, but now I'd like to upsert. There is my code:

My connexion functions:
Code:
define("SOAP_CLIENT_BASEDIR", "phptoolkit-13_0/soapclient");


require_once (SOAP_CLIENT_BASEDIR.'/SforceEnterpriseClient.php');
require_once (SOAP_CLIENT_BASEDIR.'/SforceHeaderOptions.php');
require_once ('phptoolkit-13_0/userAuth.php');

function ConnectSession($USERNAME,$PASSWORD)
{


    try 
    {
        $mySforceConnection = new SforceEnterpriseClient();
        $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
        $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);
        $_SESSION['connexion'] = $mySforceConnection;

        $_SESSION['location'] = $mySforceConnection->getLocation();
        $_SESSION['sessionId'] = $mySforceConnection->getSessionId();
        $_SESSION['wsdl'] = SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml';

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

}

function reconnect()
{
    $location = $_SESSION['location'];
    $sessionId = $_SESSION['sessionId'];
    $wsdl = $_SESSION['wsdl'];

    $mySforceConnection = new SforceEnterpriseClient();
    $sforceSoapClient = $mySforceConnection->createConnection($wsdl);
    $mySforceConnection->setEndpoint($location);
    $mySforceConnection->setSessionHeader($sessionId);

    $_SESSION['connexion'] = $mySforceConnection;
}

 


My upsert code on a 'Test_Case__c' custom object:

Code:
reconnect();

$sObject1 = new stdClass();
$sObject1->Comment__c = $_GET['comments'];
$sObject1->Id = $_GET['id'];


try
{

    $response = $_SESSION['connexion']->upsert('Comment__c',array ($sObject1));

}
catch(Exception $e)
{
    echo "Update FAILED";
    echo "erreur! ".str_replace("\n","<br>",$e);

}

 



and the response:


erreur! SoapFault exception: [sf:INVALID_FIELD] INVALID_FIELD: No such column 'Comment__c' on entity 'contact'. in C:\Dev\Workspace\CnV\phptoolkit-13_0\soapclient\SforceBaseClient.php:419

Stack trace:

#0 [internal function]: SoapClient->__call('upsert', Array)

#1 C:\Dev\Workspace\CnV\phptoolkit-13_0\soapclient\SforceBaseClient.php(419): SoapClient->upsert(Object(stdClass))

#2 C:\Dev\Workspace\CnV\phptoolkit-13_0\soapclient\SforceEnterpriseClient.php(93): SforceBaseClient->_upsert(Object(stdClass))

#3 C:\Dev\Workspace\CnV\post.php(34): SforceEnterpriseClient->upsert('Comment__c', Array)

#4 {main}


Why does uspert tries to update the contact object instead of my custom one?
I am trying to do an upsert on a custom object I created and can't seem to get it to work. I was going to the upsert sample provided in the PHP Toolkit area. I am able to create a new record just fine, but upsert gives the following error (here is just the start of the error)
SoapFault Object ( [message:protected] => INVALID_FIELD: Field name provided, NewUserID__c does not match an External ID for Contact ..
Some background. New custom object is called "New User" (New_User__C to the api) and has an external ID named NewUserID which is a text field which must be unique. All I am trying to do is change the value of one of the fields and do an update (in this example I am trying to alter the Last Name field of my record).

Here is the PHP code I am running:

Code:
<—php
define("SOAP_CLIENT_BASEDIR", "./soapclient");
require_once (SOAP_CLIENT_BASEDIR.'/SforceEnterpriseClient.php');
require_once (SOAP_CLIENT_BASEDIR.'/SforceHeaderOptions.php');

try {
  $mySforceConnection = new SforceEnterpriseClient();
  $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
  $mylogin = $mySforceConnection->login("my username", "my password");

  $sObject = new stdclass();
  $sObject->Email_Address__c = 'fake@svc.com';
  $sObject->First_Name__c = 'UserFirst';
  $sObject->Last_Name__c = 'UserLast';
  $sObject->NewUserID__c = 'aaa';

  $createResponse = $mySforceConnection->create(array($sObject), 'New_User__c');
  print_r($createResponse);

  $sObject->Last_Name__c = 'UserLast_Change';

  $upsertResponse = $mySforceConnection->upsert("NewUserID__c", array ($sObject));
  print_r($upsertResponse);

} catch (Exception $ex) {
  print_r($ex);
  echo $mySforceConnection->getLastRequestHeaders();
  echo $mySforceConnection->getLastRequest();
}
–>

So, the create statement works fine, it's just the upsert that doesn't work. What am I missing about how upsert is supposed to work? I'm pretty sure I am not grasping the way External IDs are supposed to be setup. Also, looking at the error message, it seems like it is trying to work on the Contact object?

Thanks for any help!





Message Edited by Ako on 12-05-2007 08:40 PM
  • December 06, 2007
  • Like
  • 0
Hi,
 
I'm having trouble joining 2 tables. I want to get the Account details from the opportunity.
 
My Query:
 
$query = "SELECT Opportunity.Id, Opportunity.Name FROM Opportunity, Account WHERE Opportunity.AccountId = Account.Id";
 
Result:
MALFORMED_QUERY: WHERE Opportunity.AccountId = Account.Id ^ ERROR at Row:1:Column:96 unexpected token: Account.Id
I have a client with a few million account records where we need to use a SOQL query to select a small subset (5% or so) based on a custom field value. The query is timing out due to the need to read through the entire record set. The client asked support if a custom index could be added to the filter field and was told this was not possible due to it being part of a managed package.

Is it possible to have a custom index applied to a field in the DE for the package and have that index deployed to customers? If so, can this be done in a patch org?

Thanks,
Park
 

I have a VisualPage controller which attempts to schedule an APEX task using the scheduler. It works fine as long as the job is not currently scheduled, but I am trying to catch the exception thrown when it already exists. The exception is not being caught and ends up being displayed to the user. The line displayed in the error message is the line number of the schedule call.

 

 

private ApexPages.Message ScheduleJob() { ApexPages.Message msg; String jt = '0 0 ' + cfg.Time_of_Day__c + ' * * ?'; String jn = 'BatchUpdater'; BatchUpdateRunner jo = new BatchUpdateRunner(); try { System.schedule(jn, jt, jo); msg = new ApexPages.Message(ApexPages.Severity.INFO,'The job was successfully scheduled.'); } catch (System.Exception ex) { String m = ex.getMessage(); if (m.contains('already scheduled for execution')) m += ' You may need to delete the existing job under Admin->Monitoring->Scheduled Jobs.'; msg = new ApexPages.Message(ApexPages.Severity.ERROR, m); } return msg; }

 

 

 

I'm not sure who's maintaining the toolkit at this point, but I'd like to ask for a small code change. The current createConnection method overwrites the existing HTTP_USER_AGENT value which doesn't play well with other code that relies on this value, FirePHP being one example.

 

Proposed change:

 

 

/** * Connect method to www.salesforce.com * Preserves the current HTTP_USER_AGENT * * @param string $wsdl Salesforce.com Partner WSDL */ public function createConnection($wsdl, $proxy=null) { $agent = $_SERVER['HTTP_USER_AGENT']; $_SERVER['HTTP_USER_AGENT'] = 'Salesforce/PHPToolkit/1.0'; $soapClientArray = null; if (phpversion() > '5.1.2') { $soapClientArray = array ( 'encoding' => 'utf-8', 'trace' => 1, 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP ); } else { $soapClientArray = array ( 'encoding' => 'utf-8', 'trace' => 1 ); } if ($proxy != null) { $proxySettings = array(); $proxySettings['proxy_host'] = $proxy->host; $proxySettings['proxy_port'] = $proxy->port; // Use an integer, not a string $proxySettings['proxy_login'] = $proxy->login; $proxySettings['proxy_password'] = $proxy->password; $soapClientArray = array_merge($soapClientArray, $proxySettings); } $this->sforce = new SoapClient($wsdl, $soapClientArray); $_SERVER['HTTP_USER_AGENT'] = $agent; return $this->sforce; }

 

 Thanks,

Park

 

I've added an article to the wiki on how to authenticate self service users using a modification to the PHP Toolkit. If you're looking for a simple way to validate users take a look. This one uses a modified login() call rather than the screen scrapper from the portal toolkit.

 

Self Service User Validation 

 

Park 

I'm trying to figure out how to assign territories to an account (the organization has Territory Management enabled). The Territory field is defined as a large, read-only text field, so there appears to be no easy way to assign Territory Id values to it. It also does not appear in the Enterprise WSDL (because it's read-only?). My only solution so far is to create a field on the Account and then write an assignment rule that uses that field to assign the correct territory. Not the best.

Is anyone doing any territory management via the API and have some insight into this?
We have been sending emails to users which have links to specific records in our database. The URLs have been very simple: https://na1.salesforce.com/7013000000004zzAAA. With the upcoming server moves this scheme will apparently break, or at least require an update coincident with the move.

It seems as if one can use a generic https://www.salesforce.com/login.jsp?redirect=... format, but this requires that the user log in even if they are already
logged in. The format above internally generates the correct redirection URL if the user is not logged in but takes them directly to the record if they are.

I'm wondering if there is a best practice for this sort of reference that's a bit more bulletproof.

Park
When I execute the following search I recieve the search limit (200) of random records in response, regardless of whether the email exists in the database or not:

FIND {otto.b.good@odot.state.or.us} IN EMAIL FIELDS

This appears to be related to the form of the email domain.
I'm using the v5.0 API.
There appears to be a *RECURSION* fault buried in the reply message.
The request frequently times out.

Park
I'm trying to figure out how to assign territories to an account (the organization has Territory Management enabled). The Territory field is defined as a large, read-only text field, so there appears to be no easy way to assign Territory Id values to it. It also does not appear in the Enterprise WSDL (because it's read-only?). My only solution so far is to create a field on the Account and then write an assignment rule that uses that field to assign the correct territory. Not the best.

Is anyone doing any territory management via the API and have some insight into this?

Found loads of post ofr this on this forum but none seem to be helpful in my case.

 

I create a lead in php script. Set standard and custom fields. Script works like charm.

Now I want to fill one more field that is a look up relationship.  Thi is too much for my little script, I get the fatal error.

 

I checked the profile permisssion - field is visible and writable;

I checked spelling and wsdl definition and now I'm giving up.

Can someone solve the puzzle for me

 

WSDL

<element name="Current_Gas_Supplier__c" nillable="true" minOccurs="0" type="tns:ID"/>

<elementname="Current_Gas_Supplier__r"nillable="true"minOccurs="0"type="ens:Gas_Suppliers__c"/>

 

$LeadObject->Current_Gas_Supplier__c = 'ID_fetched_from_SF';

 

insert tells me there is no such column on Lead

creating a Gas_Suppliers__c object with populated id and assigning to Current_Gas_Supplier__r changes nothing.

 

Please point me  the user/toolkit error?

thanks

 

  • June 05, 2013
  • Like
  • 0

Hi everyone,

 

I am having trouble getting the code below to work. It's pretty much copy/paste from the examples that SF provides in its documentation, hence my confusion:

 

<?php

define("USERNAME", "");
define("PASSWORD", "");
define("SECURITY_TOKEN", "");

require_once ('http://moneythink.org/apps/soapclient/SforceEnterpriseClient.php');

$mySforceConnection = new SforceEnterpriseClient();
$mySforceConnection->createConnection("http://moneythink.org/apps/soapclient/enterprise.wsdl.xml");
$mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);

$query = "SELECT Id, FirstName, LastName, Phone from Contact";
$response = $mySforceConnection->query($query);

echo "Results of query '$query'<br/><br/>\n";
foreach ($response->records as $record) {
    // Id is on the $record, but other fields are accessed via the fields object
    echo $record->Id . ": " . $record->fields->FirstName . " "
        . $record->fields->LastName . " " . $record->fields->Phone . "<br/>\n";
}

?>

 I am very new to PHP/working with API's, so my apologies if I made any basic mistakes. When I try to execute http://moneythink.org/apps/sf-app.php, which contains the code above, I just get a "Server Error" message. 

  • April 07, 2013
  • Like
  • 0

Hello, I'm trying the simple query from the docu.

using the actual  version of php toolkit.

only to try out Enterprise wsdl (works fine) and Partner wsdl on the other side.

partner wsdl doesn't give me the expected results.

I only see the id of the contact, and the other fields are combined in any- field.

I want to give out the Firstname, Lastname and so on.

here is the code:

<?php
session_start();
require_once ('soapclient/SforcePartnerClient.php');
require_once ('soapclient/SforceHeaderOptions.php');
//require_once ('soapclient/SforceEnterpriseClient.php');
define ("USERNAME", "myuser@blabla.de");
define("PASSWORD", "mypw");
define("SECURITY_TOKEN", "mytoken");

try {
    $mySforceConnection = new SforcePartnerClient();
    $mySforceConnection->createConnection("soapclient/partner.wsdl.xml");
    if (isset($_SESSION['partnerSessionId'])) {
        $location = $_SESSION['partnerLocation'];
        $sessionId = $_SESSION['partnerSessionId'];
        $mySforceConnection->setEndpoint($location);
        $mySforceConnection->setSessionHeader($sessionId);
        echo "Used session ID for partner<br/><br/>\n";
    } else {
        $mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);

        $_SESSION['partnerLocation'] = $mySforceConnection->getLocation();
        $_SESSION['partnerSessionId'] = $mySforceConnection->getSessionId();

        echo "Logged in with partner<br/><br/>\n";
    }
    $query = "SELECT Id, FirstName, LastName, Phone from Contact";
    $response = $mySforceConnection->query($query);
    $queryResult = new QueryResult($response);
    foreach ($queryResult->records as $record) {
            print_r($record);

            echo $record->Id . ": " . $record->fields->FirstName . " "
            . $record->fields->LastName . " " . $record->fields->Phone . "<br/>\n";            
    }
} catch (Exception $e) {
    echo "Exception ".$e->faultstring."<br/><br/>\n";
    echo "Last Request:<br/><br/>\n";
    echo $mySforceConnection->getLastRequestHeaders();
    echo "<br/><br/>\n";
    echo $mySforceConnection->getLastRequest();
    echo "<br/><br/>\n";
    echo "Last Response:<br/><br/>\n";
    echo $mySforceConnection->getLastResponseHeaders();
    echo "<br/><br/>\n";
    echo $mySforceConnection->getLastResponse();
}
?>

 

 

the doc says, that it works with ...

$record->fields->FirstName

 

but this works not in my case.

 

may be a simple beginner mistake - can you help me?

 

thanks a lot,

 

Adi

 

Hi!

 

I need to generate a new Enterprise WSDL for a web application built on API-version 22. However, I can only seem to generate one in ver 26, which does not seem to work out very well with the application. When switching wsdl-files (same name, same location), SOAP cannot find the new wsdl-file. Though it can find the old wsdl-file when I put it back.

 

Error message when using WSDL for ver 26:

 

 Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "/sf-lib/soapclient/enterprise.wsdl.xml" in /sf-lib/soapclient/SforceBaseClient.php on line 121

 

(I edited out some parts of the locations, but they are the same)

 

Does anyone know how to fix the location problem or how to generate a WSDL based on API ver 22?

 

Thanks in advance!

The person who set this up is no longer with the company.  I need to programatically query/extract some info from SalesForce so I can backload into Oracle or MySql  (so to csv).   

Trying to use a semi-join to filter out some Contacts to reduce rows of data.  Filter the contacts Id to a list of values from custom field in a custom object (should be so simple.... ) 

Get error about teh semi-join not being valid in current version. 

How do I identify the version installed and more importantly how can I fix this?  

(btw all relationships are 'lookups'  so i'm not having too much luck with selecting combined object info.. have to exort each object indifividually) 

 

Thank you.  

here's what I've found...  

 

WWW::Salesforce::Simple

my $sf = WWW::Salesforce::Simple->new( username => $sf_id, password => $sf_pw );

my $query ="Select Id, AccountId, LastName, FirstName, Salutation, Name, Email, Title, OwnerId FROM Contact WHERE Id IN (SELECT Channel_Partner_Manager__c FROM Office_Profile__c WHERE Lead_Source__c = 'Channel Partner' and Source_Detail__c = 'xxx123')";

my $res = $sf->do_query( $query );

UNSUPPORTED_API_VERSION:

Title, OwnerId FROM Contact WHERE Id IN (SELECT Channel_Partner_Manager__c

^

ERROR at Row:1:Column:157

Semi joins are not supported in this version of the API at ./force-get-test.pl line 127

Can't call method "fault" without a package or object reference at

/usr/lib/perl5/site_perl/5.8.8/WWW/Salesforce/Simple.pm line 42 (#4)

(F) You used the syntax of a method call, but the slot filled by the

object reference or package name contains an expression that returns a

defined value which is neither an object reference nor a package name.

Something like this will reproduce the error:

 

$BADREF = 42;

process $BADREF 1,2,3;

$BADREF->process(1,2,3);

 

Uncaught exception from user code:

Can't call method "fault" without a package or object reference at /usr/lib/perl5/site_perl/5.8.8/WWW/Salesforce/Simple.pm line 42.

at /usr/lib/perl5/site_perl/5.8.8/WWW/Salesforce/Simple.pm line 42

WWW::Salesforce::Simple::do_query('WWW::Salesforce::Simple=HASH(0x9b2e1ec)', 'Select Id, AccountId, LastName, Fi...') called at

 

 

 

date of the Simple.pm is from 2009 although it looks like this directory tree was updated in April...  

 

Thank you. 

 

I have been researching this for a couple days and don't see a solution yet. I have a php website that i want to use the credencials of salesforce to login the user to the site. So the user would just use the same username and password they use on salesforce to login to this site. Is this possible? I've seen Oauth and Rest but it doesn't really look like i could do this whit those methods. Any help would be appreciated. Thanks. 

Can I register user using PHP and API from my site?

Thx.

I'm attempting to create a php file which serves both as an IPN listner to recieve payment information from paypal, and to perform and upsert() to salesforce with the collected information. I believe that I have the gyst of the IPN listner down, as well as creating the connection to salesforce. However, I am having some trouble setting up the upsert() portion of the code. I have been looking online, and found some tutorials on this, but most of them are unclear, and usually related to databases, rather then updating from a single record (i.e. http://wiki.developerforce.com/page/Salesforce_PHP_Upsert_Tutorial). Below is the code I have come up with so far. Right now I am lost as to how to create an object with the contact's information that salesforce will be able to read using the upsert() command. Will the below code execute correctly to create a new contact in salesforce?

 

<?php
// Revision Notes
// 11/04/11 - changed post back url from https://www.paypal.com/cgi-bin/webscr to https://ipnpb.paypal.com/cgi-bin/webscr
// For more info see below:
// https://www.x.com/content/bulletin-ip-address-expansion-paypal-services
// "ACTION REQUIRED: if you are using IPN (Instant Payment Notification) for Order Management and your IPN listener script is behind a firewall that uses ACL (Access Control List) rules which restrict outbound traffic to a limited number of IP addresses, then you may need to do one of the following:
// To continue posting back to https://www.paypal.com to perform IPN validation you will need to update your firewall ACL to allow outbound access to *any* IP address for the servers that host your IPN script
// OR Alternatively, you will need to modify your IPN script to post back IPNs to the newly created URL https://ipnpb.paypal.com using HTTPS (port 443) and update firewall ACL rules to allow outbound access to the ipnpb.paypal.com IP ranges (see end of message)."


// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';

foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}

// post back to PayPal system to validate

$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";

// If testing on Sandbox use:
// $header .= "Host: www.sandbox.paypal.com:443\r\n";
$header .= "Host: ipnpb.paypal.com:443\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

// If testing on Sandbox use:
//$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
$fp = fsockopen ('ssl://ipnpb.paypal.com', 443, $errno, $errstr, 30);

// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$address_city = $_POST['address_city'];
$address_country = $_POST['address_country'];
$address_state = $_POST['address_state'];
$address_status = $_POST['address_status'];
$address_street = $_POST['address_street'];
$address_zip = $_POST['address_zip'];
$payment_date = $_POST['payment_date'];
$payment_fee = $_POST['payment_fee'];
$payment_gross = $_POST['payment_gross'];
$payment_status = $_POST['payment_status'];


if (!$fp) {
// HTTP ERROR
}
else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
if ($payment_status = "Completed") {
$wsdl = 'enterprise-wsdl.xml';
$user = 'example@epixa.com';
$pass = 'supersecure';
$token = '*****';

$client = new SforceEnterpriseClient();
$client->createConnection($wsdl);
$client->login($user, $pass . $token);

 

$sObject = new sObject();
$sObject->type = 'Contact';
$sObject->Account_Name = $first_name + $last_name;
$sObject->Address_City = $address_city;
$sObject->Address_Country = $address_country;
$sObject->Address_State = $address_state;
$sObject->Address_Street = $address_street;
$sObject->Address_Zip = $address_zip;

client.upsert('Account Name', $sObject);



}
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment

}

}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation

$mail_From = "From: me@mybiz.com";
$mail_To = "*****";
$mail_Subject = "INVALID IPN";
$mail_Body = $req;

foreach ($_POST as $key => $value){
$emailtext .= $key . " = " .$value ."\n\n";
}

mail($mail_To, $mail_Subject, $emailtext . "\n\n" . $mail_Body, $mail_From);

}
}
fclose ($fp);
}
?>

I'm a DBA who has been stuck with completing some PHP code that interacts with Salesforce through the SOAP API. I am a complete newb with PHP, SOAP and SalesForce. Great assignment, huh?

 

Got most things working by following example code, but I just cannot find a sample of how to send MySQL datetime values through the SF create() method for dateTime fields. I've tried various formats and type casts using PHP functions, but to no avail.

 

If someone could share a working code snippet of assigning a MySQL datetime to a stdclass field in PHP in the appropriate fomat to be accepeted by Salesforce's create() method, I would sure appreciate it.

 

Thanks

 

 

 

 

Hi everyone.

 

I'm new to Salesforce Toolkit 20.  Looking for info on accessing Custom fields in custom objects.

 

Query works fine in Force.com explorer and in PHP script, but output is not showing field names.  I've updated the enterprise.wdsl.xml file and clearly see the Correct custom field info in the xml file, but query looks like this:

 

$query = "Select Id, NameInfo__c, data__c from customobject"

 

and output looks like this:

 

SObject Object

(  

 [type] =>    

 [fields] =>    

  [Id] => a1eE0000000LABcIAO

)

 

SObject Object

(

[type] =>    

[fields] =>    

[Id] => a1eE0000000LABdIAO

)

 

SObject Object

(    

[type] =>    

[fields] =>    

[Id] => a1eE0000000LABeIAO

)

 

The ID can be printed with $record->ID.  How do I reference the custom fields?  Any attempt ends with "Undefined property: SObject::$NameInfo or   ...NameInfo__c     

 

Any suggestions or recommendations for where to look next?

Hello everyone,

 

I'm trying to create a form on my website that will take registrants information and feed them to Event Activity under a specific Campaign that was created in SalesForce.  I have done some research, however have gotten more and more confused.  Are there any existing PHP codes or modules that I can utilize to get this done? 

 

Any help is greatly appreciated!

 

David

Hey All,

 

We are pulling event information from our Salesforce onto our website with an API call through PHP.

This call requires Username, Password, and Security Token (obviously). The only issue with this is that passwords are forced to change and the security token changes as well.

Is there anyway to set this up statically so that it will not need to be adjusted every approx 6 months?

 

Thanks,

Kyle

Is there a way to get Opportunity status using SOQL?

 

Opportunity details page has "Delivery/Installation Status" label that shows current status value.

I need to get this value using SOQL.

 

Please help!!!

 

Thanks

Hi,

 

I'am a complete newbie to salesforce in fact just got it today.

 

my question is does the PHP toolkit allow file uploads, if so

could somebody show a sample code

 

Thanks in advanced.