I am Creating Quote from Deal using Deluge Code in Button Function.
The Quote is getting created, there is no problem, all fields are getting populated.
potDetails = zoho.crm.getRecordById("Deals",potId.toLong());
quotesubject = ifnull(potDetails.get("Deal_Name"),"");
contact = ifnull(potDetails.get("Contact_Name").get("id"),"");
account = ifnull(potDetails.get("Account_Name").get("id"),"");
description = ifnull(potDetails.get("Description"),"");
RelatedProducts = zoho.crm.getRelatedRecords("Products","Deals",potId.toLong());
product_items = List();
sub = 0.0;
for each product in RelatedProducts
{
proid = product.get("id");
proname = product.get("Product_Name");
productDesc = ifnull(product.get("Description"),"");
quantity = 1;
price = ifnull(product.get("Unit_Price"),"0.0").toDecimal();
listprice = price * quantity;
CashReceived = ifnull(product.get("Cash_Received_From_Owner"),"0.0").toDecimal();
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("Cash_Received_From_Owner_1",CashReceived.todecimal());
lineitem.put("Discount",CashReceived);
lineitem.put("list_price",listprice);
sub = sub + listprice;
product_items.add(lineitem);
}
paramap = Map();
paramap.put("Product_Details",product_items);
paramap.put("Subject",quotesubject);
paramap.put("Contact_Name",contact);
paramap.put("Account_Name",account);
paramap.put("Deal_Name",potId.toLong());
paramap.put("Description",description);
createResp = zoho.crm.createRecord("Quotes",paramap);
newid = createResp.get("id");
return "Success - Agreement Created";