deal = zoho.crm.getRecordById("Deals",dealid);
accountlookup = deal.get("Account_Name");
crm_accountid = accountlookup.get("id");
crm_accountname = accountlookup.get("name");
books_organizationid = "XXXXXXXX";
books_contactcriteria = {"contact_name":crm_accountname};
books_contact = zoho.books.getRecords("contacts",books_organizationid,books_contactcriteria,"books_all").get("contacts");
books_contactid = books_contact.get(0).get("contact_id");
info books_contactid;
books_itemlist = list();
dealproducts = deal.get("Products_of_Job");
for each dealproduct in dealproducts
{
crmproductname = dealproduct.get("Products").get("name");
item_productcriteria = {"item_name":crmproductname};
item_product = zoho.books.getRecords("items",books_organizationid,item_productcriteria,"books_all").get("items");
books_itemid = item_product.getJSON("item_id");
quantity = dealproduct.get("Quanity");
rate = dealproduct.get("Price");
//
books_itemmap = Map();
books_itemmap.put("item_id",books_itemid);
books_itemmap.put("quantity",quantity);
books_itemmap.put("rate",rate);
books_itemlist.add(books_itemmap);
}
if(books_itemlist.size() >= 1)
{
parameters_data = Map();
parameters_data.put("customer_id",books_contactid);
parameters_data.put("reference_number",deal.get("Deal_Name"));
parameters_data.put("zcrm_potential_id",dealid);
parameters_data.put("line_items",books_itemlist);
response_createInvoice = invokeurl
[
url :"https://www.zohoapis.com/books/v3/invoices?organization_id=" + books_organizationid
type :POST
parameters:parameters_data.toString()
connection:"books_all"
];
info response_createInvoice;
}