I have created a function that creates a map with various standard invoice fields:
mp = Map();
mp.put("Subject","Example Invoice Subject");
mp.put("Invoice_Date",(zoho.currentdate).toString("dd/MM/yyyy"));
mp.put("Due_Date",(zoho.currentdate).addDay(1).toString("dd/MM/yyyy"));
mp.put("Status","Draft");
mp.put("Company_Name",companyid);
It then loops through a custom module to gather the information for the Invoice Items subform on the invoice and then adds the list in to the new invoice map:
pages = {1,2,3,4,5};
productid = 210064000067345269;
sub_forms = List();
row = 0;
for each page in pages
{
mda_invoices = zoho.crm.getRecords("MDA_Invoices",page,200,{"cvid":210064000067360031});
if(mda_invoices.size() > 0)
{
for each invoice in mda_invoices
{
subform = Map();
subform.put("Row",row);
subform.put("Product",productid);
subform.put("Description",invoice.get("Name"));
subform.put("Unit_Price",invoice.get("Margin").round(2));
sub_forms.add(subform);
row = row + 1;
}
}
}
mp.put("Invoiced_Items",sub_forms);
The issue I'm having however, is when I try to create a new invoice from this map:
new_invoice = zoho.crm.createRecord("Invoices", mp);
info new_invoice;
It returns the following:
{"code":"MANDATORY_NOT_FOUND","details":{"api_name":"Product_Details"},"message":"required field not found","status":"error"}
I've looked at API Names for the Invoices module, and Product_Details isn't a mandatory field. What am I missing?