Late Fee / Custom Function / Automated WorkFlow

Late Fee / Custom Function / Automated WorkFlow

Base on some forum postings i have found, i went ahead and create a Flat Rate Late fee, which will then be run weekly with the Automated Work flow.
Please find my script i'm using:

=========================================================
//create a variable to get invoice total and add a $5 LateFee
latefee = 5;
orgID = organization.get("organization_id").toString();
invoiceID = invoice.get("invoice_id").toLong();

//display the value stored in the latefee variable
info latefee;

//add late fee and adjustment and store the total amount in the variable 'adjustment' 
adjustment = invoice.get("adjustment").toDecimal() + latefee;
jsonMap = Map();
jsonMap.put("adjustment",adjustment);
jsonMap.put("reason","Automate: Weekly Late fee");

// To update the current record
result = zoho.invoice.update("invoices",orgID,invoiceID,jsonMap);
info result.toMap().get("message");
=========================================================

Taking note that this script is updating the "Adjusment Field" and adds the late fee to what ever is in that field (I do use that field also for a Late fee for Late payment of 1st deposit).
Now when sending out my reminder email, i want to use that the "Adjustment" variable to show the client, his/her outstanding amount in latefees, however: if they did had a LatePayment for their deposit, this will be reflected also, so to avoid that this is what i did.

I created a Custom Field in the Invoice tempalte, name "LateFeeBalance"

My objective is that when i run the above script, it also takes the LATE Fee and add it to the LateFeeBalance custom field, so that i can then use this as a placeholder in my reminder email,
see example below

================================================================
Additionally we would like to inform you that a LateFee has also been added/adjusted to your previous balance.

New Late Fee Balance: ${invoice.cf_2}
Invoice Amount : %Total%  | Outstanding Balance : %Balance%





    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    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

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now