• ZCJ
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies

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
Since I can't use "DISTINCT" in a SOQL query,  I'm trying instead to return the unique values of a picklist,  using the PHP toolkit.

In the Products2 table,  I am trying to query the distinct values from the Products2.Family picklist.  I am using a query along the lines of:

Code:
$fam_query = "Select Family FROM Product2";
$fam_response = $mySforceConnection->query(($fam_query));

...

foreach ($fam_response->records as $fam_record) {
echo "<h3>".$fam_record->Family."</h3><br>";
}

Rather than returning the unique values from the picklist,  it's returning multiple family names (I guess for each product in the Products2 table?? Not sure).  So instead of:

Code:
Product Family One
Product Family Two
Product Family Three
Product Family Four
...

 I am getting:
Code:
Product Family One
Product Family One
Product Family One
Product Family Two
Product Family Two
Product Family Two
Product Family Two
Product Family Two
Product Family Three
...

I am stumped... I really just want to return the families as headers and then display the products (assets) under each family header.

Any ideas?

 

  • September 27, 2008
  • Like
  • 0
I can't find a way to find accounts whose value from a picklist START WITH a particular string. That forces me to check for all the possible values that start with it. E.g. we have Merchant: Active, Merchant: Prospective, Merchant: Committed.

It also means the code won't be forward-compatible if we add another Merchant type.

Is there no way to query for all that start with "Merchant", or even INCLUDE "Merchant" would be better than hard-coding all possibilities.