function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MikeWiresMikeWires 

API Query "Only Returns Id" Not The Requested Fields

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?

MikeWiresMikeWires
Now I KNOW somebody out there has to have experienced this and has some input.

The code I mentioned in the first post was LEFT ALONE since that post. I just pulled up the code and tested it in exactly the same way I've done before, and magically.... it works! It returns all the variables from the object.

This seems to "sometimes" happen when I create new objects or add custom fields to my org. I update my enterprise WDSL, but the fields are not accessible from a query. Its baffling!

I didn't mention my specs before, but here's what I'm using.

SF API 7.0
sForce PHP Toolkit 1.0.5 - Enterprise WDSL
Linux FC4 (2.6.11-1.1369) (PHP 5.1.4 / Zend 2.1.0)

I'm simply using a Custom Link from a closed opportunity to a self-hosted https page which does some PHP logic for processing a sale through Authorize.net. The code creates some new data utilizing custom objects (invoice / invoice line items / payment / comission), and its done. Nothing fancy. I want to publish the app on the app exchange when its finished and working, probably as open source.

Is there an easy way to view the SOAP messages themselves from the PHP tool kit functions within the process (or a PHP SOAP debug function?), as to maybe further diagnosis this oddity?

Is there some 'delay' for when an existing login session can access a newly created object? (Although I definitely tried logging out / back in, etc, etc)

Any ideas / thoughts would be appreciated.


Tran ManTran Man
You should be using the partner WSDL and never the enterprise WSDL with the PHP 1.0.5 toolkit.  This is in  the documentation that comes with the toolkit.  That should fix a bunch of the problems you are seeing.  You can print the SOAP messages by calling getLastRequest, getLastRequestHeaders, getLastResponse, and getLastResponseHeaders.  This is noted in the documentation as well.
Jack SenechalJack Senechal
Sorry I didn't see your post earlier, but I was experiencing the same issue a month or two ago. I found that in the SforcePartnerClient.php, the convertFields() function was sometimes recieving an array instead of a string. This was happening when the $response->any variable was longer than a certain amount of characters, which explains why sometimes it happens and sometimes it doesn't.

My solution was to add the following code to the top of the convertFields() function:

Code:
    if (is_array($any)) {
$any = join('', $any);
}
I meant to submit this as a bug patch but didn't get around to it yet... so, here it is!
MikeWiresMikeWires
Thank you for the replies, and the eye opening fact that I've been using the Enterprise WDSL for development when I should have been using the partner. However two months later searching out other things, I found the root of my problem... my Linux server was caching my WDSL.  *sigh*

A simple option within the /etc/php.ini file (or removing the cached copy when I updated --/tmp/wdsl-blah) was my solution to the 'mysterious' not-updating problem when using the Enterprise WDSL with the PHP5 Toolkit.

Tran ManTran Man
You should be using the Partner WSDL and not Enterprise.
Jack SenechalJack Senechal
Ah yes... the WDSL caching. I ran into that one as well.
MikeWiresMikeWires
Nick,

Thank you for pointing this our earlier and again, however when I initially got started with development I do not remember being able to even FIND documentation outlining enough details for me to understand the differences and/or the practical application of using the Partner WSDL over the Enterprise. The documentation in the package may be updated now, but if not, the toolkit should possibly include a best practices or 'overview' guide to application development. For me, the SF API was the first dabbling I ever did with SOAP messaging so the learn curve was high.

Or B) it was clearly outlined in the docs and like most programmers RTFM is the last thing that tends to happen, and its more like 'skim' than read.

On that note, if anybody out there is interested I've assembled a very elaborate payment processing tool that utilizes a number of custom SF objects for tracking invoices, orders, payments and commissions all centered around Closed Won Opportunities. The tool allows Authorize.Net gateway payment processing to your own merchant accounts. My organization has been using it internally for the past two and half months with no major issues, however the code base needs rewritten using the Partner WSDL (and cleaned) such that I can share it on the AppExchange as a free download. Its customized to our business processes, (leadsource->merchant account locks; salesfloor assistant commissions) but anyone decent in PHP could rewrite those pieces as needed. The only outstanding 'feature' not implimented is refunds, although the code is almost finished for; pushing money back to CCs and manual refunds for tracking.

A single 1900 line php application called remotely from your own https server through an Opportunity (or Invoice object) handles all the transactions.

If anyone is looking for a project, or to simply support open code, let me know.
pp_v1.2.php

Mike
Tran ManTran Man
You shouldn't ever use the enteprise WSDL with the PHP toolkit.  This is indicated in the instructions.html included with the toolkit.  To paraphrase one fo the messages on this board, the Enterprise WSDL is an early binding model which is good for strongly typed systems like Java and .NET.  The Partner WSDL is late binding, which makes it good for scripting languages like Javascript, Perl, PHP, Python and Ruby.

You will have access to all the same objects and capabilities of the API from the Partner WSDL as you do from the Enterprise WSDL.

With the new Apex Wiki, I encourage you and everyone else to participate in adding new and updating existing content that would be useful for all developers.  I added this page today for the toolkit:  https://wiki.apexdevnet.com/index.php/PHP_1.0.x_Toolkit.  Also feel free to create a payment processing tool wiki page to reach out to other people for participation.

You can use the exact same username/password for the forums to log into the wiki for editing.

Message Edited by Tran Man on 01-10-2007 09:25 PM

mattgvazmattgvaz
Mike-
Did you ever get the Authorize.net app published?  Would be a big help on a project!!
Thanks-
Matt
Mike Wires.ax284Mike Wires.ax284
Matt,

I did privately publish it for testing with High5 Software in order to try and integrate it into QB, but I haven't heard back from them in awhile on the status. I'm hesitant about publishing it publicly simply due to security flaws it might have that could end up exploited (I'm always shakey about my own code), but if you're interested email me exactly what you're trying to accomplish. mike@pfbs.com


Mike
Virath C. LiyanageVirath C. Liyanage
For Enterprise WSDL you can use in C#.NET:
sOBJECT.GetType().GetProperty(FIELDNAME.ToString()).GetValue(sOBJECT)

For partner WSDL you need to phase the XML which is described in sOBJECT.Any