Skip to main content
2 个回答
  1. 2024年2月28日 17:36

    Step 1: Create Lookup Relationship Field on Product 

    Step 2: Apex Script to Create Leads and Products 

    // Apex script to create Leads and Products and associate them

     

    List<Lead> leadsToInsert = new List<Lead>{

        new Lead(LastName='Doe', Company='Doe Inc.'),

        new Lead(LastName='Smith', Company='Smith LLC'),

        new Lead(LastName='Johnson', Company='Johnson Corp.')

    };

     

    insert leadsToInsert; // Inserting the Leads

     

    // Assuming the Leads are inserted and we have their IDs, create Products and associate them

    List<Product2> productsToInsert = new List<Product2>{

        new Product2(Name='Product A', Related_Lead__c=leadsToInsert[0].Id),

        new Product2(Name='Product B', Related_Lead__c=leadsToInsert[0].Id),

        new Product2(Name='Product C', Related_Lead__c=leadsToInsert[1].Id),

        new Product2(Name='Product D', Related_Lead__c=leadsToInsert[1].Id),

        new Product2(Name='Product E', Related_Lead__c=leadsToInsert[2].Id)

    };

     

    insert productsToInsert; // Inserting the Products

0/9000