You need to sign in to do that
Don't have an account?
gyorkoz
lead create with assignment rules: setHeader() undefined method
I'm newbie and I would like to enrich my working lead-creator API with using assigment rules.
I found that I should precede the creating code with
$useDefaultRule = new soapval('useDefaultRule', null, 'true');
$crmHandle->setHeader('AssignmentRuleHeader', array($useDefaultRule));
$useDefaultRule = new soapval('useDefaultRule', null, 'true');
$crmHandle->setHeader('AssignmentRuleHeader', array($useDefaultRule));
but it gives that setHeader() is an undefined method.
how could I fix the problem?
thanks for the answers
this link helps:
http://code.google.com/p/force-com-php-toolkit/source/browse/trunk/unit_test/Lib/Test/Partner/AssigmentRuleHeaderTest.php?r=4&spec=svn4
All Answers
I found out that lead creating is running without error with the next code:
However the assigment rule doesn't fire, the owner stay is still the creator.
what's the problem??
this link helps:
http://code.google.com/p/force-com-php-toolkit/source/browse/trunk/unit_test/Lib/Test/Partner/AssigmentRuleHeaderTest.php?r=4&spec=svn4
The PHP toolkit is generally in bad shape - including methods that seem to take assignment rul headiner info but then ignore some of their parameters.
There is actually a specific method I found for setting this header - this seems to be working for me:
// useDefaultRule boolean Specifies whether to use the default rule for rule-based assignment (true) or not (false).
// Default rules are assigned in the Salesforce.com user interface.
$header = new stdClass;
$header->assignmentRuleId = NULL;
$header->useDefaultRuleFlag = TRUE;
$sfdc->setAssignmentRuleHeader($header);
I made a fix on the SforceBaseClient.php to allow for multiple headers.
Here is the Patch :
50a51
> protected $assignmentRuleHeaders;
240a242,248
>
> $headers = $this->assignmentRuleHeaders;
>
> if ($headers != NULL) {
> $header_array = array_merge($header_array, $headers);
> }
>
340a349,371
> public function addAssignmentRuleHeader($header) {
> if ($header != NULL) {
>
> if (!isset($this->assignmentRuleHeaders)) {
> $this->assignmentRuleHeaders = array();
> }
>
> $header_values = array();
>
> if (isset($header->assignmentRuleId)) {
> $header_values['assignmentRuleId'] = $header->assignmentRuleId;
> }
>
> if (isset($header->useDefaultRuleFlag)) {
> $header_values['useDefaultRule'] = $header->useDefaultRuleFlag;
> }
>
> $this->assignmentRuleHeaders[] = new SoapHeader($this->namespace, 'AssignmentRuleHeader', $header_values);
> } else {
> $this->assignmentRuleHeaders = NULL;
> }
> }
>
Then you can use something like the following :
foreach($rules as $rule) {
$ruleHeader = new stdClass();
$ruleHeader->assignmentRuleId = $rule->id;
$this->connection->addAssignmentRuleHeader($ruleHeader);
}
This is good for when you are dinamically reading WebForms
@ Luis A. Camilo [https://www.linkedin.com/pub/luis-camilo/13/b6b/688]