• Jack Senechal
  • NEWBIE
  • 0 Points
  • Member since 2006

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 7
    Replies
Hi, I'm developing in PHP5 (5.1.6), trying to do some fairly simple object manipulation, and I'm running into a strange problem. I'm using describeSObject("Opportunity") to get a list of all the fields in the Opportunity object. Then I'm running a query to pull back that data, so that I can create a new Opportunity with some slightly altered fields.

The problem is that there seems to be a limit to the number of fields I can include in the query. If I include too many fields (more than about half of the fields returned), I still get the results back for the correct opportunity records but the SObject->fields object is empty. I have 45 fields coming back from describeSObject().

Is this a bug in the PHP API, a SOAP issue, or am I doing something wrong?

Here's some sample code:

define('_SALESFORCE', 'somdir');
define('_SF_USER_LOGIN', 'login');
define('_SF_USER_PASSWORD', 'password');

class opportunity_test
{
var $sf_client;
var $soap_client;
var $sf_login;

function __construct()
{
// setup Salesforce connection
require_once (constant('_SALESFORCE').'/soapclient/SforcePartnerClient.php');
$this->sf_client = new SforcePartnerClient();
$this->soap_client = $this->sf_client->createConnection(constant('_SALESFORCE').'/partner.wsdl.xml');
$this->sf_login = $this->sf_client->login(constant('_SF_USER_LOGIN'), constant('_SF_USER_PASSWORD'));
}

public function get_opps()
{
$fields = $this->get_opp_fields();
$query = "SELECT $fields FROM Opportunity WHERE Id = 'SOME_OPPORTUNITY_ID'";
$result = $this->sf_client->query($query);
$opps = array();
foreach ($result->records as $record)
{
$s_object = new SObject($record);
$oppid = $s_object->Id;
$opps[$oppid] = $s_object;
}
return $opps;
}

/**
* Get a comma separated list of the fields in the opportunity object
*
* @return string
*/
public function get_opp_fields()
{
$desc = $this->sf_client->describeSObject("Opportunity");
$fields = array();
foreach ($desc->fields as $field)
{
$fields[] = $field->name;
}
sort($fields);
$result = join(',', $fields);
return $result;
}
}

$opptest = new opportunity_test();
$opps = $opptest->get_opps();
var_dump($opps);

Message Edited by Jack Senechal on 10-06-200603:51 PM

How can I auto fill fields based on a lookup field in my custom object edit page?  Basically,  after I select an Account for my custom object, I want the account address and contact info filled into the other fields of my custom object.  How can this be done easily?
 
All help is greatly appreciated...
I've been working with the SF API for awhile now, and have a quirky problem. I've noticed this several times, when I executing a piece of code similar to the following query / PHP....

      $query = "Select Assistant_Commission_Percent__c, Assistant_Name__c, CreatedById, CreatedDate, Id, LastModifiedById, LastModifiedDate, Name, OwnerId, Strategist_Commission_Percent__c, Strategist_Name__c,  SystemModstamp from User_Commission__c where UserId__c ='". $_POST['OwnerId'] ."'";
      $result = $sforce->query(array("queryString" => $query));
     if(isset($debug)){
      echo "User Commission Object<br>";
      echo $query;
      echo "<pre>";
      print_r($result);
      echo "</pre>";
      }
 
I get the following return...

User Commission Object
Select Assistant_Commission_Percent__c, Assistant_Name__c, CreatedById, CreatedDate, Id, LastModifiedById, LastModifiedDate, Name, OwnerId, Strategist_Commission_Percent__c, Strategist_Name__c, SystemModstamp from User_Commission__c where UserId__c ='00530000000uXmoAAE'
stdClass Object
(
[result] => stdClass Object
(
[done] => 1
[queryLocator] =>
[records] => stdClass Object
(
[Id] => a0B50000000JYp3EAG
)
[size] => 1
)
)
The query syntax is correct, even the result (Id) is correct, but I ONLY get the Id of the object I'm looking at returned. I am using the enterprise WDSL, and it is updated. In the past, its seems that leaving the code alone for a day fixes the problem, and 'magically' 24 hours later the same code returns all the fields I requested. (Yes, I might be losing my mind with a statement like that.)

Any ideas what is causing this and/or has anyone experienced a similar problem?

Hi,

sorry if this question is misplaced here, but I couldn't find any other list to place this question to.

I am not yet very familiar with the philosophy of SalesForce, but as I understand so far: if I use SalesForce, I don't need a traditional in-house infrastructure of servers and software distribution and the like. Right? Ok, but what if I am forced by law to store the data gathered by my company within the physical boundaries of my company and I am not allowed too to store the data encrypted outside of my company?

For instance, I think of clinical data of a hospital information system. Some governments may not allow that data to be stored outside of the physical areas of the hospital, even not if they would be encrypted. Is there any chance to use software on demand like SalesForce in this context? Has SalesForce a feature like: "local data, but remote business logic" or doesn't make this sense at all (i.e., "the database is the system")?

Thank you in advance for any comments.

Regards.
Hi, I'm developing in PHP5 (5.1.6), trying to do some fairly simple object manipulation, and I'm running into a strange problem. I'm using describeSObject("Opportunity") to get a list of all the fields in the Opportunity object. Then I'm running a query to pull back that data, so that I can create a new Opportunity with some slightly altered fields.

The problem is that there seems to be a limit to the number of fields I can include in the query. If I include too many fields (more than about half of the fields returned), I still get the results back for the correct opportunity records but the SObject->fields object is empty. I have 45 fields coming back from describeSObject().

Is this a bug in the PHP API, a SOAP issue, or am I doing something wrong?

Here's some sample code:

define('_SALESFORCE', 'somdir');
define('_SF_USER_LOGIN', 'login');
define('_SF_USER_PASSWORD', 'password');

class opportunity_test
{
var $sf_client;
var $soap_client;
var $sf_login;

function __construct()
{
// setup Salesforce connection
require_once (constant('_SALESFORCE').'/soapclient/SforcePartnerClient.php');
$this->sf_client = new SforcePartnerClient();
$this->soap_client = $this->sf_client->createConnection(constant('_SALESFORCE').'/partner.wsdl.xml');
$this->sf_login = $this->sf_client->login(constant('_SF_USER_LOGIN'), constant('_SF_USER_PASSWORD'));
}

public function get_opps()
{
$fields = $this->get_opp_fields();
$query = "SELECT $fields FROM Opportunity WHERE Id = 'SOME_OPPORTUNITY_ID'";
$result = $this->sf_client->query($query);
$opps = array();
foreach ($result->records as $record)
{
$s_object = new SObject($record);
$oppid = $s_object->Id;
$opps[$oppid] = $s_object;
}
return $opps;
}

/**
* Get a comma separated list of the fields in the opportunity object
*
* @return string
*/
public function get_opp_fields()
{
$desc = $this->sf_client->describeSObject("Opportunity");
$fields = array();
foreach ($desc->fields as $field)
{
$fields[] = $field->name;
}
sort($fields);
$result = join(',', $fields);
return $result;
}
}

$opptest = new opportunity_test();
$opps = $opptest->get_opps();
var_dump($opps);

Message Edited by Jack Senechal on 10-06-200603:51 PM

Hi all,
I am trying to get all contact data by using query() method with SOQL: "Select Id, LastName, FirstName,... From contact".
Is there any simple statement can do the same thing? (such as "Select * From contact" in SQL)
 
Thanks in advance.