Skip to main content
public class DMLhelper

{

    public  static void createBulkprospects()

    {

        List<Lead>lstleads=new List<Lead>();

        for(integer counter=1;counter<=100;counter++)

        {

            Lead ld = new Lead();

            ld.firstname='Bulk';

            ld.LastName='Lead record'+counter;

            ld.Company='salesforce INC';

            ld.Status='Warm';

            ld.Industry='Technology';

            ld.phone='9900998877';

            ld.fax='9900778899';

            ld.Email='bulked'+counter+'@gmail.com';

            ld.LeadSource='Web';

            

        }

        if(!lstleads.isempty())

            Insert lstleads;

        system.debug('number of DML statements used..:'+Limits.getDmlStatements());

        

    }

   Execution code=classname.Methodname

DMLhelper.createbulkprospects();

but i got error like variable DMLhelper doesnot exist
1 respuesta
  1. 10 mar 2022, 5:37
    Hi Prashanth,

    I have used the below code i anonomous code and it did not throw any error.

     

    DMLhelper.createBulkprospects();

    In the code you are not adding lead to the list so leads were not creating. Updated the code as below.

    public class DMLhelper

    {

    public static void createBulkprospects()

    {

    List<Lead>lstleads=new List<Lead>();

    for(integer counter=1;counter<=100;counter++)

    {

    Lead ld = new Lead();

    ld.firstname='Bulk';

    ld.LastName='Lead record'+counter;

    ld.Company='salesforce INC';

    ld.Status='Warm';

    ld.Industry='Technology';

    ld.phone='9900998877';

    ld.fax='9900778899';

    ld.Email='bulked'+counter+'@gmail.com';

    ld.LeadSource='Web';

    lstleads.add(ld);

    }

    if(!lstleads.isempty())

    Insert lstleads;

    system.debug('number of DML statements used..:'+Limits.getDmlStatements());

    }

    }

    If this solution helps, Please mark it as best answer.

    Thanks,

     
0/9000