• James W.ax741
  • NEWBIE
  • 5 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    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

I have a custom object in our Salesforce setup called AgentProducts, when I do a query (code running in php) via the API the only field I can get back is Id;

 

select Id, User_Id__c from AgentProducts__c

 

returns a record for every one of the entries in AgentProducts, but only with the Id field;

Array
(
    [0] => stdClass Object
        (
            [Id] => a0350000008xWWKAA2
        )

    [1] => stdClass Object
        (
            [Id] => a0350000008xWWLAA2
        )
etc. 

 

Even worse, if I filter the query by something like my custom email field, I get back the correct Id for the correct account, but still, no further data;

select Id, User_Id__c from AgentProducts__c where Email__c='xxx@xxxxx.xxx'

 

returns:

stdClass Object
(
    [Id] => a0350000008xWWMAA2
)

 

Any ideas?  I've been looking through the online documentation but I can't find anything on custom objects needing special treatment.

 

I can't query a custom formula field in the product2 object. I don't get an error when I put it in the SOQL SELECT statement, but I can't select it. I can select it from the Excel Connector, so it must be possible. Code:
$query_all_products = "select Id, ProductCode, Quantity__c, Warehouse_Location__c, WeightOunces__c, Shipping_Weight_Formula__c from product2";
$result = $sforce->query(array("queryString" => $query_all_products));
$all_products=$result->result->records;
echo '<pre>'.print_r($all_products,true).'</pre>';
Warehouse_Location__c
doesn't show up in the resulting object.And when I try using describeSObject:
$contact= $sforce->describeSObject("Contact");
print_r($contact);
I get this error: Fatal error: Uncaught SoapFault exception: [sf:INVALID_TYPE] INVALID_TYPE: sObject type cannot be null in (filename):3 Stack trace: #0 [internal function]: SoapClient->__call('describeSObject', Array) #1 (filename)(3): SoapClient->describeSObject('Contact') #2 {main} thrown in (filename) on line 3 Any ideas?
  • October 03, 2007
  • Like
  • 0