Getting started with the Custom Functions:
1. Go to Settings -> Automation -> Custom Functions.
2. Create a new Custom function. Provide a name for the function.
3. Choose the module as 'Invoice' and click on 'Create Custom Events'.
4. Choose Date Based workflow type and Date of Execution as 1 day(s) after Expected Payment Date. You can also set a different Execution Time based on your requirement.
5. In order to run the function for unpaid invoices, Apply Advanced Filter as When Status isn't Paid.
6. Copy the code which was given above.
7. Save the Custom function and you are good to go.
Further Enhancements:
1) While using this custom function, there might be a scenario where you would like to exclude a few of your prime customers' subscription from being cancelled automatically without your consent. In order to do this, you can add a Custom Field of type CheckBox to the Subscription.
While creating a subscription, you can leave this CheckBox marked (or) unmarked in order to differentiate your prime customers from others. Later, you can add this custom field in the Addition Criteria of your workflow, such that the workflow is executed only for your non-prime customers.
Please refer the below image for your reference, where the CheckBox custom field is named as "Cancel subscription automatically?".
2) When the subscription is cancelled, the last renewed invoice will still be in open status. If you would like to void that invoice before cancelling the subscription, you can modify the workflow to address that need.
Found this useful? Try it out and let us know how it works! If you have questions, do not hesitate to ask!
Cheers,
Sasidaran K,
Zoho Subscriptions.