Function #31: Auto-populate warranty expiry date of items in invoices

Function #31: Auto-populate warranty expiry date of items in invoices



Hello everyone, and welcome back to our series!

Warranties play a vital role in influencing a customer's decision to buy a product. They represent a guarantee from the manufacturer or seller that the product will meet specific standards of quality and performance for a specified timeframe. During this timeframe, customers have the right to file claims for any defects or damages that may occur on the products. In most cases, the warranty period begins with the purchase date. Today, we have written a custom function that will automatically calculate the Warranty expiry date for items in invoices. 

Here's how it works:

When you add items to an invoice, just choose the appropriate warranty period for each item using a dropdown-type custom field. After you save the invoice, the function is executed, automatically filling in the warranty expiry date in another custom field. This calculation is based on the invoice date and the chosen warranty period.




Pre-requisites:

1. Create a Connection named "zbooks" to successfully execute the function. You can watch the GIF attached below to learn how to create the connection.



2. Create a dropdown-type custom field named "Warranty period [In Months]" for the items. Add the different warranty periods (such as 3 months, 6 months, 9 months, 12 months, etc) as the drop-down options of this custom field. Ensure the same unit of measurement for all the listed warranty periods.


3. Create another date-type custom field called "Warranty Expiry date" for the items. Based on the invoice date and the warranty period chosen, the function will populate the expiry date in this field. 



Custom Function:

Navigate to Settings -> Automation -> Custom Functions -> +New Custom Function > Add the function code from this GitHub link and be sure to replace cf_warranty_period_months and cf_warrant_expiry_date in the script with the actual API names of the custom fields you have created. 
 
Workflow Rule: 
 
Go to Settings -> Automation -> Workflow Rules -> +New Workflow Rule and set up the workflow rule as shown below:-





In the final step of this workflow rule, associate the custom function you created and then hit Save.

If you're a business owner looking for a method to show the warranty expiry date on invoices, give this function a try and share your feedback in the comments. If you require additional customizations, feel free to reach out to us at support[at]zohobooks[dot]com with your specifications. We are happy to help!

Regards,
Shireen Farhana
Zoho Books