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
chuckdubdubchuckdubdub 

Using lead assignment rules when inserting new lead records

I've been doing some reading and I think I'm *almost* there.  I'm doing the following to attempt to use the lead assignment rules, but it isn't working -- I get NULL results. 

$leadassign = new soapval('autoAssign', 'boolean', 'TRUE');

    $contact = new sObject('Lead',
                           null,
                           array(
                               'salutation' => $_POST['salutation'],
                               'FirstName' => $_POST['first_name'],
                               'LastName' => $_POST['last_name'],
                                 'Company' => $_POST['company'],
                                 'email' => $_POST['email'],
                                'LeadSource' => $_POST['lead_source'],
                                'Street' => $_POST['street'],
                                'City' => $_POST['city'],
                                'State' => $_POST['state'],
                                'Phone' => $_POST['phone'],
                                'PostalCode' => $_POST['zip'],
                                'Country' => $_POST['country'],
                               'MobilePhone' => $_POST['mobile'],
                               $leadassign                           )                          
                          );
    $createResult = $sfdc->create($contact);
  print_r("\ncreate one: \n\n");
print_r($createResult);


Thanks for any help!!

Chuck
chuckdubdubchuckdubdub
Aha, never mind.  I precede all the insert code with this info, and it works:



    $useDefaultRule = new soapval('useDefaultRule', null, 'true');
    $sfdc->setHeader('AssignmentRuleHeader', array($useDefaultRule));

gyorkozgyorkoz

hi,

 

your code doesn't work for me. the first thing: I only found setHeaders() method and not setHeader() which was private in the SForceBaseclinet.php so I had to change it to public.

After then, lead creating gives me the error 'Invalid SOAP Header'

Is anything else I have to set up in my code??

 

thanks