respMap = zoho.crm.getRecordById("Sales_Orders",input.soId.toLong()); productDet = ifnull(respMap.get("Product_Details"),""); pdlist = List(); for each eachProd in productDet { productvalue = eachProd.get("product"); proid = productvalue.get("id"); proname = productvalue.get("name"); mp = Map(); mp.put("product",{"name":proname,"id":proid}); mp.put("quantity",ifnull(eachProd.get("quantity"),"0").toLong()); mp.put("list_price",ifnull(eachProd.get("list_price"),"0.0").toDecimal()); mp.put("discount",ifnull(eachProd.get("discount"),"0.0").toDecimal()); mp.put("total",ifnull(eachProd.get("total"),"0.0").toDecimal()); mp.put("net_total",ifnull(eachProd.get("net_total"),"0.0").toDecimal()); pdlist.add(mp); } paramap = Map(); paramap.put("Product_Details",pdlist); paramap.put("Subject",ifnull(respMap.get("Subject"),"")); paramap.put("Contact_Name",ifnull(respMap.get("Contact_Name"),"").get("id")); paramap.put("Account_Name",ifnull(respMap.get("Account_Name"),"").get("id")); paramap.put("Owner",ifnull(respMap.get("Owner"),"").get("id")); paramap.put("Sales_Order",ifnull(respMap.get("id"),"")); paramap.put("Terms_and_Conditions",ifnull(respMap.get("Terms_and_Conditions"),"")); paramap.put("Description",ifnull(respMap.get("Description"),"")); paramap.put("Adjustment",ifnull(respMap.get("Adjustment"),"0.0").toDecimal()); paramap.put("Discount",ifnull(respMap.get("Discount"),"0.0").toDecimal()); paramap.put("Tax",ifnull(respMap.get("Tax"),"0.0").toDecimal()); paramap.put("Shipping_Cuty",ifnull(respMap.get("Shipping_Cuty"),"")); paramap.put("Shipping_Code",ifnull(respMap.get("Shipping_Code"),"")); paramap.put("Shipping_Method",ifnull(respMap.get("Shipping_Method"),"")); paramap.put("Shipping_State",ifnull(respMap.get("Shipping_State"),"")); paramap.put("Shipping_Street",ifnull(respMap.get("Shipping_Street"),"")); paramap.put("Status",ifnull(respMap.get("Status"),"")); createResp = zoho.crm.createRecord("Purchase_Orders",paramap); info paramap; info createResp; |
Writer is a powerful online word processor, designed for collaborative work.