How To Update a custom field on an invoice

How To Update a custom field on an invoice

Hello Zoho,

For integration with a payment provided I need to pass an amount in cents without currency.

To accomplish this I have done the following steps.

1. Create a new custom field "totalcents" under Preferences >> Invoices >> Custom Field with default value of 99
2. I have created a workflow "Set totalcents" under Automation >> Workflow
2.1 Rule triggers whenever  invoice is created / edited and the "Total" field is updated
3. Created a custom function called totalcents that executes as follows to set the custom field value

invoiceID = invoice.get("invoice_id");
organizationID = organization.get("organization_id");
totalcents = invoice.get("total").toNumber() * 100;
invoice.put("cf_totalcents",totalcents);
zoho.books.updateRecord("Invoice",organizationID,invoiceID,invoice);
info invoice.get("cf_totalcents");

When I execute this the value of "cf_totalcents" prints as expected.

In my email template I have a dynamically generated url that is defined as follows:
https://<payment_provider>/qr/Wts8aSung?id=%InvoiceNumber%&amp;amount=${invoice.cf_totalcents}"

When the email template is generated, the value of cf_totalcents remains as 99 instead of the invoice total.
Please advise how to make it use the correct value.

Thank you.