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
bresbobresbo 

Lead Assignment Rules

Does anyone have some code for setting the Lead Assignment Rule (or default rule)
when creating a lead using the PHP API talking to version 4.0 sforce?

Thanks.
RichardSRichardS

Hi there,

I am assuming your are using the PHP classes provided in the sForce repository.  If so, you can do what I have done below as a means of using the rules you have in place for leads and or cases.   If you intend to use rules all the time.  This is found in the SalesforceClient.php file

function addSessionHeader()
    {
        $header = new SOAP_Header(
                '{urn:partner.soap.sforce.com}SessionHeader',
                NULL,
                array('sessionId' => $this->sessionId),
                0);
        $this->addHeader($header);

        //For Testing
        $ruleHeader = new SOAP_Header(
                '{urn:partner.soap.sforce.com}AssignmentRuleHeader',
                NULL,
                array('useDefaultRule' => 'true'),
                0);
        $this->addHeader($ruleHeader);
    }

bresbobresbo
Brilliant - thanks very much indeed.