Activity Forums Salesforce® Discussions How To Force Lead Assignment Rule Via Apex While Updating Or Adding The Lead?

  • chanchal kumar

    Member
    September 4, 2018 at 2:26 pm

    Hello Prachi,

    To enforce Assignment Rules in Apex you will need to perform following steps:

    1. Instantiate the “Database.DMLOptions” class.
    2. Set the “useDefaultRule” property of “assignmentRuleHeader” to True.
    3. Finally call a native method on your Lead called “setOptions”, with the Database.DMLOptions instance as the argument.

    // to turn ON the Assignment Rules in Apex

    Database.DMLOptions dmlOptn = new Database.DMLOptions();

    dmlOptn.assignmentRuleHeader.useDefaultRule = true;
    leadObj.setOptions(dmlOptn);

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos