Saturday, July 11, 2020

Applying Lead assignment rule when inserting bulk data from data loader (Trigger solution)

Problem : When inserting lead from data loader lead reassignment rules are                        not working on records.


solution : when you are using lead assignment rules you have to check the                        checkbox Assign using active assignment rule on lead and it                                 works fine . 


Assignment Rule

Problems arise when you have to insert bulk data. In this case the lead assignment rule does not work . 

So what i do i found this solution by writing after insert trigger on lead . I use apex DML operation. Here useDefaultRule  is the default assignment rule set by the user. 

        

Here is my code :


,
                   Trigger onAfterInsert on Lead(After insert)
                    public static List<Lead> leads = new List<Lead>();
                        {
                            for (Lead l : Lead_ids)
                                {
                                    leads.add(new Lead(Id = l.Id));
                                }

                             Database.DMLOptions dmo = new Database.DMLOptions();
                             dmo.assignmentRuleHeader.useDefaultRule = true;
                             Database.update(leads, dmo);
                        }



  Thanks,
  Lovesalesforceyes.

No comments:

Post a Comment

Get selected radio button value in LWC

This post explains how to get selected radio button in LWC. Below is demo of output : To use the radio button in LWC you have to use the  li...