How to write a custom function in Zoho Books to calculate commision for every invoice sent?

102 Views Asked by At

I am writing a custom function in Zoho Books using Deluge.

I don't know how to get the total price from invoice and generate a commission on a custom field when an invoice got generated, saved, or sent.

I have tried running the following code, but because I don't know what variable saves the total price on invoices, I can't calculate commission.

I write something like;

organizationID = organization.get("organization_id");
invoiceID = invoice.get("invoice_id");
invoice_resp = zoho.books.getRecordsByID("Invoices",organizationID,invoiceID);
invoice_data = invoice_resp.get("invoice");

// total_commission = (total_value_on_invoice / 100) * 3;

update_map = {"custom_fields":{{"customfield_id":"26837000000008275","value":total_commission}}};
update_resp = zoho.books.updateRecord("Invoices",organizationID,invoiceID,update_map);
0

There are 0 best solutions below