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
jhilgemanjhilgeman 

PHP Toolkit 11.0 - Assignment Rules and Query Options not working per docs

This new upgrade to 11.0 has been quite the adventure in testing. Two quick things:

1. AssignmentRule - working but not per docs.


Okay, so per the specs in the documentation listed here:

http://path/to/the/toolkit/apidocs/SalesforceSoapClient/SforcePartnerClient.html#methodcreate

The create method still accepts an AssignmentRule object as a valid second argument. In fact, the script didn't complain when I left it in. But when I tried to create a lead with it, the assignment rule didn't get executed, and was not even present in the request sent to the server (which is why it didn't work).

I didn't see any clear documentation to support this besides the name, but using $connection->setAssignmentRuleHeader($AssignmentRuleObject)
worked and properly assigned the new lead. Also, when constructing a new AssignmentRule object, the docs say that the first argument should be an int type, but it doesn't look like it's enforced anywhere in the code (which is good, because the rule ID is not an integer). So maybe the data type should be changed from "int" to "string" or "mixed" or something?

2. QueryOptions - not limiting the recordset

I nearly copied the code verbatim from the online samples, but still no go. Limiting the batch size doesn't work:

Code:
$options = new QueryOptions(1);
$client2->setQueryOptions($options);
$rules=$client2->query("Select Id,Name,SobjectType from AssignmentRule where SObjectType='Lead'");
print_r($rules);

I have 3 lead assignment rules, and all 3 of them come back, instead of just 1 as specified in the QueryOptions. The quantity doesn't matter - it can be 1 or 100, but the limit doesn't work. The last line of that code will dump a stdClass object with 3 records in it. Changing the code to use a QueryResult object doesn't seem to make a difference, either. It just changes the type of object that is dumped by print_r to "QueryResult" instead of "stdClass" - the data is the same.

If I try printing out the last request and response immediately after using setQueryOptions, it doesn't look like there was any request/response that went to the server - I just see the data from a describeSObject request that occurred earlier in the testing script.

Are the 11.0 adopters the guinea pigs? :)

- Jonathan
SuperfellSuperfell
the batchSize in QueryOptions is a hint, nothing else, and in most cases the minimum is 200, even if you ask for less. This is covered in detail in the regular API docs.
jhilgemanjhilgeman
One follow-up note: if I also dump the contents of the connection object right before the query, I do see this, which seems to indicate that the QueryOptions object was understood and correctly set. But it still doesn't make a difference in what comes back.

    [queryHeader:protected] => SoapHeader Object
        (
            [namespace] => urn:partner.soap.sforce.com
            [name] => QueryOptions
            [data] => Array
                (
                    [batchSize] => 1        <------------- set by new QueryOptions(1)
                )

            [mustUnderstand] =>
        )
jhilgemanjhilgeman
Thanks for the response.

Am I looking in the wrong places for docs? What I'm looking at is the stuff inside the "apidocs" folder inside the toolkit zip file, and those docs are bare-bones, to say the least - looks like they were auto-generated from the source using phpDocumentor or something. I've felt like I've been flying blind for a while - either figuring out stuff by looking at the code or by asking others.

SuperfellSuperfell
Would appear so, see the web services API docs

http://www.salesforce.com/us/developer/docs/api/index.htm
Tran ManTran Man
You are right, the apidocs in the zipfile are autogenerated and incomplete.  Reference these samples for now:  http://wiki.apexdevnet.com/index.php/PHP_Toolkit_11.0_Samples.