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
sandy sfdcsandy sfdc 

How to call Database.Dmloptions from api

Hi,
I need to send Lead information to salesforce from Php with AssignmentRule,can anyone guide how to implement below apex logic from Api(php) 

Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule= true;
Lead l = new Lead(company='Facebook', lastname='Smith');
l.setOptions(dmo);
insert l;


My PhP sample code:

define("SOAP_CLIENT_BASEDIR", "../../soapclient");
require_once (SOAP_CLIENT_BASEDIR.'/SforcePartnerClient.php');
require_once (SOAP_CLIENT_BASEDIR.'/SforceHeaderOptions.php');
require_once ('../userAuth.php');
try {
  $mySforceConnection = new SforcePartnerClient();
$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/partner.wsdl.xml');
$mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);
  $fields = array (
     'FirstName' => 'John',
    'LastName' => 'Smith',
    'Phone' => '510-555-5555',
    'Company' => 'Facebook'
);
$sObject = new SObject();
$sObject->fields = $fields;
$sObject->type = 'Lead';
$createResponse = $mySforceConnection->create(array($sObject));
print_r($createResponse);


 
Andy BoettcherAndy Boettcher
Sadly you cannot do this via REST yet (as of my last check) but you can do this via the SOAP API - https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_header_assignmentruleheader.htm
sandy sfdcsandy sfdc
Thank u Andy..