I'm having a major issue getting an invoice to send on create via the following deluge script:
projectIdLong = input.projectId.toLong();
projectDetails = zoho.crm.getRecordById("Deals",projectIdLong);
// info "project data: " + projectDetails;
// docs received field
docsReceived = ifnull(projectDetails.get("Documents_Received"),false);
// questionnaire field
questionnaire = ifnull(projectDetails.get("Questionnaire_Engagement_Rec_d"),false);
// empty if no invoice exists
invoiceSent = ifnull(projectDetails.get("Tax_Return_Invoice_Sent"),false);
// checks the return form number
returnFormNumber = ifnull(projectDetails.get("Form_Number"),"");
contact = projectDetails.get("Contact_Name");
contactId = contact.get("id");
// checks if either box has been checked
if(docsReceived == true || questionnaire == true)
{
// checks if an invoice has already been created
if(invoiceSent == false)
{
individualId = XXXXXXXXXXXXXXXX713;
businessId = XXXXXXXXXXXXXXXX612;
if(returnFormNumber == "1040 Federal" || returnFormNumber == "1040X Amended")
{
lineItemID = individualId;
lineItemName = "Individual Tax Return";
}
else
{
lineItemID = businessId;
lineItemName = "Business Tax Return";
}
rate = 200.00;
quantity = 1;
searchTerms = Map();
searchTerms.put("zcrm_contact_id",contactId);
clientReturn = zoho.books.getRecords("Contacts",XXXXXX360,searchTerms,"custominvoiceautomation");
// contact_persons_detail = clientReturn.getJSON("contact").getJSON("contact_persons");
// info "CONTACT PERSONS: "+contact_persons_detail;
clientlist = clientReturn.get("contacts");
client = clientlist.get(0);
clientId = client.get("contact_id");
info "client ID: " + clientId;
rate = 200.00;
quantity = 1;
todaysDate = today;
todaysDateFormatted = todaysDate.toString("yyyy-MM-dd");
info "today's date: " + todaysDateFormatted;
invoiceMap = Map();
lineItemList = list();
lineItems = Map();
lineItems.put("item_id",lineItemID);
lineItems.put("name",lineItemName);
lineItems.put("rate",rate);
lineItems.put("quantity",quantity);
lineItemList.add(lineItems);
invoiceMap.put("customer_id",clientId);
invoiceMap.put("date",todaysDateFormatted.tostring());
invoiceMap.put("line_items",lineItemList);
invoiceMap.put("send",true);
info "invoice map: " + invoiceMap;
invoiceReturn = zoho.books.createRecord("Invoices",XXXXXX360,invoiceMap,"custominvoiceautomation");
info invoiceReturn;
}
When I create and send an invoice manually, and then pull the invoice data via a deluge script, It shows me the contact person, but I can't seem to find a contact person before to send one via a deluge script.
}