Back to Automation

Workflow Scenarios

Workflows can come in handy if you wish to get things done automatically in Zoho Books. Following are some of the scenarios where workflows come into play.

Scenarios for Email Alerts

Scenario 1:

Dillion Inc. is a garment export company. The VP of sales wants to receive email alerts when an employee raises a quote for an amount greater than $10,000 for one of their top customers. This will help them offer their best services. In that case, a workflow can be designed to automatically trigger email alerts when the following conditions are met.

Execute When: Created
Rule Criteria: Total amount due is greater than $10,000.
Immediate Action: Email alert to the VP of Sales/ Finance team.
Time Based Action: —

Scenario 2:

Joseph, the CTO of Bookworm.com, an online bookstore wants to implement a system wherein an alert message should be triggered to the packing section, upon raising an invoice for an order placed by the customer. The Email Alerts feature allows him to accomplish this by creating a workflow rule with the following parameters.

Execute When: Created or Edited
Rule Criteria: Contact Name is XYZ
Immediate Action: —
Time Based Action: Email alert to the packing section upon raising an invoice.

Scenario 3:

Adrian is the head of the travel department at Fossil Petrocorp, a company that specializes in finding efficient ways to use non-renewable sources of energy. Their engineers keep travelling across the globe to do business with major petroleum companies. Adrian’s job is to make sure their air tickets are booked and paid for by the company on time. So, whenever Adrian books a flight ticket for his colleagues through their travel agent, he wishes to send an acknowledgement mail to the agent that they have received the bill and would make the payment before the due date.

Execute When: Created or Edited
Rule Criteria: Company Name is ABC Travel Agency and Status is Open. Immediate Action: —
Time Based Action: Email alert to the travel agent upon creating a bill for the air tickets.

Scenarios for Field Updates

Scenario 1:

Andrew is the Head of Marketing of SolarSync, a solar panel manufacturing company. According to his newly issued directive, the sales person should be changed to “XYZ” as soon as the sales person “ABC” has landed the sale i.e when an invoice for a Total Amount greater than $10,000 has been created or edited. A workflow automates the process of re-assigning the task to another person by setting up the following parameters to execute the directive.

Execute When:   Created or Edited
Rule Criteria: When Sales Person is “ABC” and Total and Total Amount is greater than $10,000.
Immediate Action: Update Sales person field to “XYZ”
Time Based Action: —

Scenario 2:

MobileCave Inc. owns a chain of stores that sells mobile phones. They constantly order phones from different vendors. The purchase department often faced the difficulty of receiving the shipments on time as their vendors also supply to several other stores in the city.

The purchase department figures out a way to overcome this by alerting the vendor a week before their promised delivery date. According to the purchase team, this can be achieved by creating a workflow that will be executed whenever a purchase order was raised for $2000 or more.

Also, another action was set to update the Notes field that has a short message to the vendor requesting them to deliver the goods on time and if they did, they can expect more orders from MobileCave Inc. in the future.

Execute When:   Created or Edited
Rule Criteria: When Company Name is “ABC” OR Total is greater than $2000.
Immediate Action: Update Notes field with a message to deliver the goods on time.
Time Based Action: Email Alert 7 days before Expected Delivery Date.

Scenario 3:

Andrew is the owner of Phoenix Rent-a-Car, a car rental company in Chicago. One of his regular customers has rented a car for a month. Andrew sends him an invoice for $1500 for a period of 30 days i.e $50/day i.e $1500/month. He has also offered his customer a discount of $500. However, he wishes to update the Customer Notes 10 days after the Quote Date by offering him a few freebies as well. He can automate this task by setting up the following parameters.

Execute When: Created or Edited
Rule Criteria: When Total=1000 and Discount > 500.
Immediate Action: —
Time Based Action: Update the field Customer Notes 10 days after Quote Date.

Scenarios for Webhooks

Scenario 1:

Greg is the Public Relations manager for a Home & Office Security company. A First-Time customer had asked for a quotation for setting up security systems for his office in Boston. Greg wants to make a good impression by promptly sending a ‘Thank You’ SMS as soon as he accepts the quote. The webhooks feature in automation can do that by setting the following parameters and connecting to a SMS gateway.

Execute When: Created or Edited
Rule Criteria: When Contact Name is “XYZ” and Contact Type is “Customer”.
Immediate Action: SMS alert using a webhook with SMS gateway.
Time Based Action: —

Scenario 2:

Frank is the financial controller of a Stock Brokerage firm. Most of the company’s revenue is credited into the company’s official Stripe account. He wants to be notified of any high value deposits or withdrawals towards invoices or expenses from that account via Email or SMS, on a weekly basis. He can achieve that by setting up a webhook using the following parameters.

Execute When: Created or Edited
Rule Criteria: When Total Amount>=$10,000
Immediate Action: —
Time Based Action: Trigger SMS 7 days after Rule Trigger Date

Scenario 3:

Simon is the CEO of a start-up called Food4Fun which provides meals to the employees of big companies located in the Bay Area. He has got about 5 clients. His company incurs expenses on a daily basis for ingredients, transport, gas and employees’ salary who are paid by the hour. His accountant Jane has asked him to upload the receipts of expenses incurred for transportation so that she can verify it and bill it to their clients. So whenever Simon creates an expense for transportation at the end of the day, the receipt automatically gets uploaded to a cloud storage service that can also be accessed by Jane.

Execute When: Created or Edited
Rule Criteria: When Expense Account is Travel Expense AND Is Billable is True.
Immediate Action: Expense Receipts are uploaded to a cloud storage service using Webhooks.
Time Based Action: —

Scenarios for Custom Functions

Scenario 1:

Applying a 10% discount if your invoice total exceeds $2500

Sarah runs a supermarket and she wishes to provide discounts to celebrate her store’s 10th Anniversary. She decides to give a 10% discount for anybody who makes a purchase for $2500 or more. It would a painful task to include discount everytime she creates an invoice.

With the help of custom function, she can write a small piece of code to execute this action.

Sarah can set a condition where if the total of the invoice exceeds $2500, the function will be excuted and a 10% discount will be applied.

Now, let’s look at how the custom function would look for this scenario.

Custom function name: Discount

Description: Apply a 10% discount when the invoice total exceeds $2500

Module: Invoice

Script:

//create a variable and get invoice total
total = invoice.get("total").toDecimal();
//set a condition: when invoice amount is >= 2500
if ( total >= 2500.00 )
{
adjustment = invoice.get("adjustment").toDecimal();
adjustment = adjustment - total * 0.10;
jsonstring = "{\"adjustment\":" + adjustment + ",\"reason\":\" DISCOUNT \"}";
// To update the current record
zoho.books.updateRecord("Invoices", organization.get("organization_id"), invoice.get("invoice_id"), jsonstring.toMap());
}

She then creates a workflow rule with the following parameters.

Workflow Rule Name: Anniversary discount

Module: Invoice

Workflow type: Event based

When an invoice is: created

Triggers: When total >= 2500

Actions: Custom functions - Discount

Now, when the invoice total is greater than or equal to $2500, the workflow will be triggered and the custom function will be executed.


Scenario 2:

Adding a 5% late fee when an invoice becomes overdue

Dennis runs a self-storage facility in Manhattan where customers can store anything in a box, small enough to safely store documents and, big enough to store an expensive car. He charges his clients the option to pay on a daily, weekly, monthly or even a yearly basis. He offers them a 10-day grace period from the invoice date to make the payment after which, he charges an additional 5% of the invoiced amount as late fees.

Using Zoho Books, he writes a small code using Custom Functions to automatically calculate the late fees and add it as adjustments in the invoices when the invoices become Overdue.

Now, let’s look at how the custom function would look for this scenario.

Custom function name: Latefee

Description: Apply a 5% late fees on the invoice amount

Module: Invoice

Script:

//create a variable to get invoice total and add a 5% late fee
latefee = invoice.get("total").toDecimal() * 0.05;
//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;
jsonstring = "{\"adjustment\":" + adjustment + ",\"reason\":\" late fee\"}";
// To update the current record
result = Map();
result = zoho.books.updateRecord("Invoices", organization.get("organization_id"), invoice.get("invoice_id"), jsonstring.toMap());
info result;

She then creates a workflow rule with the following parameters.

Workflow Rule Name: Late fee

Module: Invoice

Workflow type: Date based

Date of Execution: 0 day(s) after Due Date

Execution time: Enter the time of execution

Execution cycle: Once

Triggers: When > Status > isn’t > Paid > AND > Status > isn’t > Partially Paid

Now, when the invoice due date exceeds the set date (in the workflow rule), the workflow will be triggered and the custom function will be executed.


Scenario 3:

Provide discount if payment for the invoice is made before the due date

Donna runs a design firm that creates promotional materials for websites on a monthly basis. This involves designing brochures, banner ads, and other promotional materials. Donna sends invoices at the end of each month and often receives payment only after the credit period, which is 30 days. To receive funds immediately, she decides to offer a discount if the invoice amount was paid before the invoice due date.

In order to implement this, she adds a discount of 5% to her invoices and in the customer notes section she mentions that the discount would be applicable only if the payment is made before the due date.

To make this work, Donna writes the following custom function.

//if payment for the invoice is received after the invoice due date then discount won't be applied
jsonstring = "{\"discount\" : 0, \"reason\" : \"over duedate exceed\"}";
zoho.books.updateRecord("invoices", organization.get("organization_id"), invoice.get("invoice_id"), jsonstring.toMap());

Once done, she creates a workflow to execute ths custom function. The parameters of the workflow rule is mentioned below:

Workflow rule name: Discount for early payment

Module: Invoice

Workflow type: Date based

Date of Execution: 0 day(s) after Due Date

Execution time: Enter the time of execution

Execution cycle: Once

Trigger: When > Status > isn’t > Paid

Actions

Type: Custom function and Name: Name of your custom function

So, if an invoice reaches the due date, the workflow will be triggered and the custom function will add 0% discount instead of the actual 5%


Scenario 4:

Automatically set due date for an invoice as 30 days before the event date (that is entered via a custom field)

Tom is a creative wedding photographer. His client book for his services 2-3 months prior to the wedding date.(Event date.) And, Tom would confirm the date only if the client pays the full amount 30 days before the wedding date. In order to streamline this process, Jake, one of the members of Tom’s studio writes a small custom function.

To start with, Jake creates a custom field named “Wedding Date” with the date datatype and writes the following custom function


customFields = invoice.get("custom_fields").toList();
cfDate = null;
for each  customField in customFields
{
customField = customField.toMap();
if(customField.get("label") == "Date")
{
cfDate = customField.get("value");
}
}
duedate = cfDate.toTime().subMonth(1);
info duedate;
duedate = duedate.year() + "-" + text(duedate.month(),"00") + "-" + text(duedate.day(),"00");
jsonstring = "{\"due_date\":" + duedate + ",\"reason\":\" Duedate changed. \"}";
result = zoho.books.updateRecord("invoices",organization.get("organization_id"),invoice.get("invoice_id").toString(),jsonstring.toMap());
info result;

After creating the custom function, Jake creates a workflow rule to trigger it. The parameters of the workflow rule are as follows:

Workflow name: Payment 30 days before the wedding

Module: Invoice

Workflow type: Event based

When invoice is: Created

Actions

Type: Custom function and Name: Name of your custom function

While creating an invoice, if Tom mentions the wedding date in the custom field, the workflow will be triggered and the custom function will set the due date of the invoice to 30 days before the wedding date.


​Scenario 5:

Automatically cancel a quote if its not accepted within 10 days from the date of creation.

Katherine owns a company that supplies automotive spare parts to several automobile service stations. Several customers ask her for a quote, but a portion of them fail to communicate their decision by neither accepting nor rejecting the quote. To avoid this, Katherine decides to decline the quote if she doesn’t hear back from the client within 10 days from the receipt of the quote. To implement this, she writes a custom function.

\\get quote and organization ID
quoteid = quote.get("quote_id");
orgid = organization.get("organization_id");

\\convert the status of the quote to 'declined'
result = invokeUrl
[
url: "https://books.zoho.com/api/v3/quotes/" + quoteid + "/status/declined?organization_id=" + orgid
type: POST
connection: "books_api_connection"
];

Learn more from the Connections help document.

Now, to trigger the execution of this custom function, she creates a workflow rule with the following parameters.

Workflow Name: Decline quote after 10 days of receipt

Module: Quotes

Workflow type: Date Based

Date of Execution: 10 day(s) after Created Time

Execution time: Enter the time of execution

Execution cycle: Once

Criteria: When > Quote Status > is > Sent > AND > Quote Status > is > not approved

Actions

Type: Custom function and Name: Name of your custom function

Now, when the quote exceeds 10 days from its created time, the workflow will be triggered and the custom function will be executed to change the status of the quote to declined.


Scenario 6:

Extend due date by 7 days if the customer pays 50% of the invoice amount on or before the initial due date

Diane owns a store that supplies printing paper and office stationery for offices in her area. She wants to extend the due date of the invoice by a week if customers pay 50% of the invoice amount on or before the initial due date.

In order to do that, she writes the following custom function:

//Getting invoice total, balance after the partial payment, and due date
inv_total = invoice.get("total").toDecimal();
inv_balance = invoice.get("balance").toDecimal();
inv_duedate = invoice.get("due_date").toDate();
orgid = organization.get("organization_id");
invid = invoice.get("invoice_id");
//Condition to check if the amount paid is 50% of the invoice amount
if(inv_balance == inv_total / 2)
{
inv_duedate = inv_duedate.addDay(7);
inv_duedate = inv_duedate.year() + "-" + text(inv_duedate.month(),"00") + "-" + text(inv_duedate.day(),"00");
//Update the due date by 7 days
jsonstring = "{\"due_date\" : " + inv_duedate + ", \"reason\" : \"Due date extended\"}";
result = zoho.books.updateRecord("invoices",orgid,invid,jsonstring.toMap());
}

Once done, Diane creates a workflow rule to execute the custom function.

Workflow name: Extend due date

Module: Invoice

Workflow type: Event based

When invoice is: Edited

Execute the workflow When any field is updated

Just once or Everytime? Just once

Triggers When > Status > is > Partially paid

Type: Custom function and Name: Name of your custom function

Now, when a customer pays 50% of the invoice amount by the initial due date, a grace period of 7 days will be given for him to pay the balance amount.

Was this document helpful?
Yes
No
Thank you for your feedback!
Want a feature?
Suggest
Switch to smart accounting software. Switch to Zoho Books.   Start my free 14-day trial

Books

Online accounting software
for small businesses.