I am successful in creating the quote from a deal, but it is pulling the product info from the Products related list and not my products subform I created in the deal
I need all the data from the deal products subform to populate the product table in the quote
here is the code I am using to create a quote now, i need the related list completely out of the picture and the product subform to populate the quote product table
potDetails = zoho.crm.getRecordById("Deals",potIdStr.toLong());
paramap = Map();
if(ifnull(potDetails.get("Contact_Name"),"") != "")
{
contact = ifnull(potDetails.get("Contact_Name").get("id"),"");
paramap.put("Contact_Name",contact);
}
if(ifnull(potDetails.get("Account_Name"),"") != "")
{
account = ifnull(potDetails.get("Account_Name").get("id"),"");
paramap.put("Account_Name",account);
}
RelatedProducts = zoho.crm.getRelatedRecords("Products","Deals",potIdStr.toLong());
product_items = List();
for each product in RelatedProducts
{
proid = product.get("id");
proname = product.get("Product_Name");
productDesc = ifnull(product.get("Description"),"Manque Description Produit !!!");
quantity = 1;
price = ifnull(product.get("Customer_Price"),"0.0").toDecimal();
listprice = price
* quantity;
lineitem = Map();
lineitem.put("product",{"name":proname,"id":proid});
lineitem.put("product_description",productDesc);
lineitem.put("quantity",quantity);
lineitem.put("net_total",listprice);
lineitem.put("total",listprice);
lineitem.put("Customer",listprice);
product_items.add(lineitem);
}
paramap.put("Product_Details",product_items);
paramap.put("Subject",ifnull(potDetails.get("Deal_Name"),""));
paramap.put("Deal_Name",potIdStr.toLong());
paramap.put("Description",ifnull(potDetails.get("Description"),""));
createResp = zoho.crm.createRecord("Quotes",paramap);
info paramap;
info createResp;
newid = ifnull(createResp.get("id"),"");
if(newid != "")
{
openUrl("https://crm.zoho.com/crm/EntityInfo.do?module=Quotes&id=" + newid,"same window");
return "New Quote created successfuly";
}
else
{
return "Quote could not be created. Missing product details in Deal.";
}