Zoho Invoice custom function for Estimate module
Hi!
I using invoice.zoho.
I want to update
"quantity" after push custom fields (Ex: NightQty and Qly):
quantity = NightQty * Qly
I created a custom function for Estimate module in Custom functions tab:
estimateID = estimate.get("estimate_id");
organizationID = organization.get("organization_id");
estimateMap = zoho.books.getRecordsByID("Estimates",organizationID,estimateID).get("estimate").toMap();
itemJSON = estimateMap.get("line_items").toList();
updatedLineItems = List();
for each item in itemJSON
{
item_CFs = item.get("item_custom_fields").toList();
updatedLineItem = Map();
updatedLineItem.put("line_item_id",item.get("line_item_id"));
nights = 0;
roomqty = 0;
for each item_cf in item_CFs
{
if(item_cf.get("label").equalsIgnoreCase("NightQly"))
{
nights = item_cf.get("value").toDecimal();
}
else if(item_cf.get("label").equalsIgnoreCase("Qly"))
{
roomqty = item_cf.get("value").toDecimal();
}
}
qty = nights * roomqty;
updatedLineItem.put("quantity",qty);
updatedLineItems.add(updatedLineItem);
}
json = Map();
json.put("line_items",updatedLineItems);
response = zoho.books.updateRecord("Estimates",organizationID,estimateID,json);
info response.get("message");
And I added to "Workflow Rules". But this function not working and I receive error:
Custom Function Estimate failed to execute for the workflow Update Estimate.
by Zoho Invoice.
This code worked on Invoice module with "zoho intergration" like "zoho.invoice.getRecordByID()" and "zoho.invoice.update()".
Can help me?
Access your files securely from anywhere
Zoho Developer Community
Deliver unforgettable customer experiences
Deliver unforgettable customer experiences
New to Zoho Marketing Plus?
Everything you need to run your marketing
New to Zoho Marketing Plus?
Everything you need to run your marketing
Zoho Desk Resources
Desk Community Learning Series
Zoho TeamInbox Resources
Zoho DataPrep Resources
Zoho CRM Plus Resources
Zoho Books Resources
Zoho Subscriptions Resources
Zoho Projects Resources
Zoho Sprints Resources
Qntrl Resources
Zoho Creator Resources
Zoho Campaigns Resources
Zoho CRM Resources
Zoho Show Resources
Writer Get Started. Write Away! Writer is a powerful online word processor, designed for collaborative work.