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
Madhu 3027Madhu 3027 

how to insert list of products and pricebooks in its child junction object named as pricebookentry from soap webbservice using soap ui tool

Madhu 3027Madhu 3027
Please find the code i have written below.but it has errors .can anyone please help me with it.
global class ProductsAndPricebooksAndEntry {
    public List<ProdctsInfo> info{get;set;}
    // This is our wrapper/container class.
  global class ProdctsInfo {

      webservice  String name;
     webservice String type;
     webservice String category;
     webservice Decimal price;
      webservice Pricebook2 pricebookName;
      webservice PricebookEntry pricebookentryName;
  }
 
  webservice static List<Product2> createProduct(List<ProdctsInfo> info) {
      //Our collection of the Product objects 
   List<Product2> pro = new  List<Product2>();
     List<Pricebook2> pricebookList=new  List<Pricebook2>(); 
      for(ProdctsInfo i:info){
             Product2 product =new Product2();
            product.name=i.name;
            product.Product_Type__c= i.type;
            product.Product_Category__c= i.category;
            product.Product_Price__c=i.price;
           // As each ProductsInfo is processed we create a new Product object and add it to the ProductList  
           pro.add(product);
          Pricebook2 pb=new Pricebook2();
          pb.Name=String.valueOf(i.pricebookName);
          pricebookList.add(pb);
          
          PricebookEntry pbe=new PricebookEntry();
     //     pbe.Name=string.valueOf(i.pricebookentryName);
      }
    
    insert pro;
    insert pricebookList;  
    return pro;
  }
}