Automation

Automation allows you to create a set of rules for modules of Zoho Billing based on which appropriate actions would be performed. A good example would be the case where a congratulatory e-mail is sent automatically to the team members when a quote for goods worth over $1000 gets accepted by a client. In the next few steps, you will be learning about:

To get started with workflows:

Workflow Scenarios

Workflows can come in handy if you wish to get things done automatically in Zoho Billing. 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 the 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.



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 Email Alert 7 days after Rule Trigger Date


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 be a painful task to include discount everytime she creates an invoice.

With the help of custom functions, 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 executed 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();
orgID = organization.get("organization_id").toString();
invoiceID = invoice.get("invoice_id").toLong();
//set a condition: when invoice amount is >= 2500
if ( total >= 2500.00 )
{
	adjustment = invoice.get("adjustment").toDecimal();
	adjustment = adjustment - total * 0.10;
	jsonMap = Map();
	jsonMap.put("adjustment", adjustment);
	jsonMap.put("reason", "discount");
	// To update the current record
	result = zoho.invoice.update("invoices", orgID, invoiceID, jsonMap);
	info result.toMap().get("message") ;
}

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% latefee 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 customers 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 Billing, 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% discount
latefee = invoice.get("total").toDecimal() * 0.05;
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","Late fee");
// To update the current record
result = zoho.invoice.update("invoices",orgID,invoiceID,jsonMap);
info result.toMap().get("message");

He 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

Actions: Custom functions - Latefee

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
orgID = organization.get("organization_id").toString();
invoiceID = invoice.get("invoice_id").toLong();
jsonMap = Map();
jsonMap.put("discount", 0);
jsonMap.put("reason", "reached due date.");
result = zoho.invoice.update("invoices", orgID, invoiceID, jsonMap);
info result.toMap().get("message") ;

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


orgID = organization.get("organization_id").toString();
invoiceID = invoice.get("invoice_id").toLong();
customFieldList = invoice.get("custom_fields").toList();
cfDate = null;
for each  customField in customFieldList
{
	customFieldMap = customField.toMap();
	if(customFieldMap.get("label") == "Date")
	{
		cfDate = customFieldMap.get("value");
		break;
	}
}
duedate = cfDate.toTime().subMonth(1);
info duedate;
duedate = duedate.year() + "-" + text(duedate.month(),"00") + "-" + text(duedate.day(),"00");
jsonMap = Map();
jsonMap.put("due_date", duedate);
jsonMap.put("reason", "Auto due date.");
result = zoho.invoice.update("invoices", orgID, invoiceID, jsonMap);
info result.toMap().get("message");

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 an 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://billing.zoho.com/api/v3/quotes/" + quoteid + "/status/declined?organization_id=" + orgid
type: POST
connection: "billing_api_connection"
];

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: Quote

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").toString();
invid = invoice.get("invoice_id").toLong();
//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
	jsonMap = Map();
	jsonMap.put("due_date", inv_duedate);
	jsonMap.put("reason", "Increased due date");
	result = zoho.invoice.update("invoices", orgid, invid, jsonMap);
	info result.toMap().get("message") ;
}

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.


Scenarios for In-App Notifications

Scenario 1:

KYZ shoe company decides to offer freebies to all the customers who purchase from them. The finance team should be notified each time an invoice is paid, so that they can send out the freebies. They created a workflow that would internally notify the finance team whenever an invoice moves to the paid status.

Scenario 2:

Peter is the head of ABC organization. Whenever a credit note is raised, Peter would like to notify the head of the production department. This will help the production team to work on their shortcomings and improve their service. For this, they will need to create a workflow to notify the production department.


Setting up a new workflow rule

A workflow rule consists of  actions that comprises of emails alerts, , and Webhooks that play an essential role in executing a task. A workflow rule may employ one or more actions to accomplish the task. To set up a workflow rule in Zoho Billing, navigate to Settings > Automation > Workflow Rules.

Name your workflow

Field Description
Workflow Rule Name Give a unique name for the workflow rule.
Module Select the module for which you wish to create a workflow.
Description Give a small description for your workflow rule.

Choose when to trigger a workflow

You can choose when to trigger the workflow based on the parameters you select in the following fields.

Workflow Type

There are two types of workflows:

Event Based:

If the workflow is Event Based, then the workflow is triggered when a module is:

When a module is Edited or Created or Edited, additional fields appear.

Field Description
Execute the workflow when There are 3 options to choose from
-When any field is updated.
-When any selected field is updated.
-When all selected field are updated.
If you select When any selected field is updated or When all selected fields are updated in the drop-down, an additional box will appear where you can select any 3 fields of the module.
Just Once or Overtime? Just Once- The workflow would be executed when the criteria is met for the first time.
Everytime- The workflow would be executed everytime the criteria is met.

Date Based:

If the workflow is Date Based, the following fields appear.

Field Description
Date of Execution Select the workflow to be triggered on any number of days before or after Module Date, Expiry Date or Created Time from the drop down.
Execution Time You may choose the exact time of execution by selecting the corresponding hh or mm of your organisation’s time zone.
Execution Cycle You may choose the frequency of triggering a workflow by choosing Once, Monthly or Yearly from the drop down.

Filter the triggers

Filter the triggers section allows you to set one or more conditions based on which the action will be executed.

Field Description
Condition The filter will be triggered based on the criteria you set. You can also add multiple criteria by clicking on + Add Criteria based on which the workflow rule will be executed.
The condition for the next criteria may be AND or OR depending on whether you wish to include both or either one of the criteria. Also, you can change the criteria pattern as you want by selecting Change Criteria.
Field Attributes The field is used to select an attribute from the list that broadly covers the terms that are related to the module.
Rules Select the rules based on which the system should filter the trigger.
Value Field Enter the value of the attribute for which the filter must be applied.

Editing Criteria Pattern:

You can edit the criteria pattern to suit your requirements by selecting Change Criteria. The editor allows you to define a pattern of your choice using simple AND/OR logic. For example, if you wish to trigger the workflow rule When Quote Number is 1 AND either Quote Status isn’t Invoiced OR Total is equal to 500,

The pattern is (((1)AND 2) OR 3). If you feel the criteria pattern does not match your requirement, you can edit it to be (1AND (2 OR 3)).

Click Save to continue.

Note: You can have a maximum of 10 criteria for each Workflow Rule.

Actions

Once the rules have been set, the actions to be taken upon encountering the conditions has to be decided. You can customize the actions to suit your business needs and program it to act immediately or at a particular time.

Immediate Actions:

Field Description
Type Select one of the three types of actions,
-Email Alerts
-Webhooks
You can also add multiple actions by clicking on +Add New Actions.
Name The field should contain the name of the Email Alert, or Webhooks. For example, in the case of an email alert, you can either pick the ones from the list you have already created or you can add a new one by selecting + Add New Email Alert.
Follow the same steps for and Webhooks.
Details The details of the action is displayed here.

Time Based Actions: If you wish to schedule actions for a particular time, select the check box next to Would you like to add time based actions?. This will display additional fields to enter the desired time.

Field Description
Execution Time Enter the desired number of days before or after,
-Rule Trigger Date
-Module Date
-Expiry Date
-Created Time
-Modified Time

Next, select the type of action that you wish to take. It can be an Email Alert, Field Update or a Webhook. You can also add multiple time based actions by selecting +Add New Time Based Action.

Note: You can add a maximum of 5 time based actions. Also, each time based action can have a maximum of 5 actions.

Finally, click Save to create the workflow rule to implement it for the modules in Zoho Billing.

Other Actions

You can also mark your workflow rules as Active or Inactive. To do so, hover the cursor and select Mark as Active or Mark as Inactive. To delete the workflow rule, click the Trash icon.

Edit a workflow rule: You can edit a workflow rule by simply clicking on one of the workflow rules from the list or by hovering over a workflow rule and select edit.

Filter workflow rules: To filter the workflow rules list, follow these steps:

You can also filter workflow rules based on whether they are active or inactive. Based on your selection, the corresponding workflow rules will be displayed as a list.

Note:


Email Alerts

The following steps will explain how to set up an email alert for any module in Zoho Billing.

Creating a new Email Alert:
To set up an email alert:

Field Description
Name Give a unique name for the email alert.
Module Select the module for which you wish to create an email alert.
Email Template You can pick a template from the drop down or click + Add New Email Template if you wish to create a new one.
Email Recipients Pick customers from the drop down, to whom you wish to send the email alerts.
Additional Recipients If you wish to send out email alerts to more people, enter their email addresses separated by a comma. Please note that you can add a maximum of 10 additional recipients.

Click Save to create a new email alert. You can now select one of the many email alerts created, from the drop down, to notify you when a workflow is triggered.

Other Actions

Delete an email alert:

To delete an email alert, hover the cursor next to an email alert on the list and click the Trash icon.

Filter email alerts:

To filter the email alerts list, follow these steps:

Based on your selection, the corresponding email alerts will be displayed as a list.

Note:


Webhooks

Webhooks facilitate communication with third-party applications by sending instant web notifications every time an event occurs in Zoho Billing. With Webhooks, you can configure HTTP & HTTPS URLs and associate them with workflow rules to automate the notification process.

For general information about webhooks, visit webhooks.org.

Create a Webhook

To set up a webhook:

You can also add additional query parameters by clicking Add Parameters and entering the required values in the Key and Value fields. You can add custom parameters like Auth Token, Security Token, API Key, etc.

Secure Your Webhooks

Securing your webhooks can help verify that the webhooks were sent from Zoho Billing. To do this, you have to set up your server so that it listens for webhooks from Zoho Billing. When your server receives a webhook from Zoho Billing, a hash value must be generated based on the payload and your secret token. Once done, check if it matches the hash value from Zoho Billing and thereby validate the source of the webhook. This can add a layer of security by enabling your server to disregard third-party webhooks pretending to originate from Zoho Billing.

Validate Webhooks

When your server receives the webhook, a hash value will have to be generated for the payload in the same way that Zoho Billing generated it. This is necessary to produce the same hash value to validate the webhook.

The following parameters (if available) are used to generate the hash value:

Construct a string by sorting the payload’s key-value pairs in alphabetical order. The pairs must be sorted in alphabetical order with respect to their keys.

Note * If your webhook contains **query string parameters**, ensure that those key-value pairs are sorted along with the payload’s key-value pairs. * There cannot be any spaces between the key-value pairs.

Once you’ve sorted the key-value pairs and constructed the string, append the raw JSON to the end of the string.

Examples

1. Default Payload

Query string parameters’ key-value pairs:

subscription\_id=90343, name=basic

Default payload/raw JSON:

{"created\_date":"2023-10-11","event\_id":"5675"}

The constructed string would be:

namebasicsubscription\_id90343{"created\_date":"2023-10-11","event\_id":"5675"}

2. x-www-form-urlencoded

Query string parameters’ key-value pairs:

customer\_name=Brandon, status=active

x-www-form-urlencoded payload’s key-value pairs:

addon\_description=Monthly addon, quantity=1

The constructed string would be:

addon\_descriptionMonthly addoncustomer\_nameBrandonquantity1statusactive
Pro Tip * If your payload is in the x-www-form-urlencoded format, the entire string must be decoded before generating the hash value. * If one of the key value pairs contains spaces, the spaces must also be included in the constructed string.

The hash value can be computed by applying the HMAC-SHA256 algorithm on this string, along with the secret token that was used in Zoho Billing.

You can then validate the webhook by checking if the hash value computed from your side matches the one in the header (X-Zoho-Webhook-Signature) of the webhook from Zoho Billing.

Configuring SMS Gateways 

You can set up webhooks to send and receive message alerts through SMS gateways. All you have to do is configure the SMS gateways using the URL and follow the steps provided below.

Bulk SMS

Bulk SMS is a popular SMS Gateway and is compatible with over 800 mobile network providers, worldwide.

URL: https://bulksms.vsms.net/eapi/submission/send_sms/2/2.0?username=%username%&password=%password%&msisdn=${CONTACT.CONTACT_MOBILE_PHONE}&message=%message_content%

To configure the URL for Bulk SMS:

Note: If there are other punctuations in your message content, you can check how to replace them with modifiers from this website. However, ensure that you do not replace punctuations that are essential to the message’s syntax.

After formatting your message with %20 for blank spaces and %2C for commas, it should look like this:

URL: https://bulksms.vsms.net/eapi/submission/send_sms/2/2.0?username=%username%&password=%password%&msisdn=${CONTACT.CONTACT_MOBILE_PHONE}&message=Hello%20${CONTACT.CONTACT_NAME}.Thank%20you%20for%20the%20purchase%20of%20${INVOICE.INVOICE_TOTAL}

Similarly, other SMS gateways can be configured, with only the URL being different. 

SMS-Magic

SMS gateways such as SMS-Magic requires you to enter additional entity parameters to configure the webhook.

To configure SMS-Magic:


<?xml version="1.0"?>
<m:Library xmlns:m="http://screen-magic.com" xmlns="http://www.defns.com">
<userid>**User_ID**</userid>
<senderid>**%Sender_ID**</senderid>
<accountid>**%Account_ID**</accountid>
<hashkey>**%hashkey%**</hashkey>
<message mobilenumber="${CONTACT.CONTACT_MOBILE_PHONE}" >
<![CDATA[${INVOICE.INVOICE_TOTAL}]]>
</message>
</m:Library>

Replace the placeholders in the URL with the User ID, Sender ID and Account ID of your SMS-Magic account. The hashkey refers to a standard hashed md5 value of a string that is a concatenation of your User ID, Password, Account ID and Sender ID.

Note: To generate the hashed md5 value, you can visit this site

Text Local

Text Local requires an entity parameter and a custom parameter to function.

To configure Text Local:

Other Actions

Delete Webhooks

To delete a webhook:

The webhook will be deleted. If you’ve used in the webhook in a workflow rule, ensure that you update the workflow rule as the workflow rule might not get triggered.

Filter Webhooks

To filter the webhooks list, follow these steps:

Based on your selection, the corresponding webhook will be displayed as a list.

Note:


Events

Events enables you resend/check the status of your webhooks in Zoho Billing.

To check the status of your webhook:

To resend a webhook,


Custom Functions

Custom functions in Zoho Billing allows you to write small pieces of code to automate your business processes. Be it providing a special discount on your customers’ invoice, or adding a late fee when an invoice becomes overdue, all you have to do is write a piece of code using Deluge script and link it to a workflow rule and automation of the process will be taken care of.

What is Deluge?

Deluge(Data Enriched Language for the Universal Grid Environment) is an online scripting language integrated with Zoho Creator. It enables users to add logic to the application, incrementally, making it more powerful and robust.

To know about Deluge, refer the Deluge Reference Guide.

If you wish to learn Deluge by writing code samples, click here.

Creating and Executing a Custom function

To setup a custom function,

Now, the next step is to create a workflow rule using the newly created custom function.

Now, whenever the criteria is met, the workflow rule will be triggered, which in turn will trigger the custom function.

Default fields

As of now, custom functions support User, Organization, Quote, Invoice, Customer, Recurring Invoice, Expense and Item modules.

These modules will have the following fields from which you can get the necessary parameters for your custom function.

User

The user field supports the following parameters:

Key Fields Description
name Name of the user
zuid ZUID of the user

Organization

The organization map supports the following fields:

Key Fields Description
organization_id Your organization ID
name Organization name
time_zone Time zone of your organization
language_code Organization’s language
date_format Your organization’s date format
currency_id Currency ID
currency_code Currency code
currency_symbol Currency symbol
address Organization address
phone Organization’s contact number
fax Fax number
website Organization URL
email Email address
portal_name Portal name of your organization

Sample map:

{
	"time_zone": "Asia/Calcutta",
	"language_code": "en",
	"currency_id": "7605000000000099",
	"phone": "99999999999",
	"fax": "check",
	"website": "",
	"email": "charles@zylker.com",
	"address": {
		"zip": "624001",
		"country": "India",
		"city": "New Delhi",
		"street_address2": "Block 15",
		"street_address1": "6/35 Garden Lane,",
		"state": "Delhi"
	},
	"organization_id": "12345678",
	"name": "Zlyker Industries",
	"date_format": "dd MMM yyyy",
	"currency_symbol": "Rs.",
	"portal_name": "zylkerindustry",
	"currency_code": "INR"
}

Quote

The quote map supports the following fields:

Key Fields Description
quote_id Quote ID
quote_number Your quote number
date Quote date
reference_number Reference number of your Quote
status Status of your quote
customer_id ID of the customer who is assigned to the quote
customer_name Your customer name
currency_id Currency ID
currency_code Currency code
currency_symbol Currency symbol
exchange_rate Exchange rate involved in the quote
expiry_date Expiry date of the quote
discount_amount Discount amount
discount Discount
shipping_charge Shipping charge entered in the quote
adjustment Adjustments
sub_total Sub total of the quote
total Quote total
tax_total Total tax amount in the quote
billing_address Billing address of the customer
shipping_address Shipping address of the customer
notes Notes
terms Terms and conditions
custom_fields Quote custom fields
salesperson_id ID of the salesperson
salesperson_name Name of the salesperson

Sample map:

{
	"total": "12000.0",
	"terms": “checking",
	"quote_id": "7605000000320001",
	"date": "2016-06-03",
	"quote_number": "EST-000026",
	"shipping_address": {
		"zip": "94588",
		"country": "USA",
		"address": "4910 Hopyard Rd",
		"city": "Pleasanton",
		"state": "CA",
		"fax": “Fax Number”
	},
	"salesperson_name": “Salesperson”,
	"adjustment": "0.0",
	"currency_symbol": "Rs.",
	"salesperson_id": "7605000000336089",
	"currency_code": "INR",
	"shipping_charge": "0.0",
	"custom_fields": [
		{
			"customfield_id": "7605000000190011",
			"is_active": true,
			"show_in_all_pdf": false,
			"value_formatted": "Check-6",
			"data_type": "autonumber",
			"index": 1,
			"label": "auto number",
			"show_on_pdf": false,
			"value": "Check-6"
		}
	],
	"currency_id": "7605000000000099",
	"exchange_rate": "1.0",
	"status": "invoiced",
	"sub_total": "12000.0",
	"customer_name": “Customer”,
	"discount_amount": "0.0",
	"discount": "0.0",
	"tax_total": "0.0",
	"reference_number": “Ref number”,
	"notes": "Looking forward for your business.",
	"expiry_date": "2016-06-03",
	"customer_id": "7605000000258011",
	"billing_address": {
		"zip": "94588",
		"country": "USA",
		"address": "4910 Hopyard Rd",
		"city": "Pleasanton",
		"state": "CA",
		"fax": "Fax Number"
	}
}

Invoice

The invoice map supports the following fields:

Key Fields Description
due_date Invoice due date
payment_expected_date Expected payment date for the invoice
reference_number Reference number of the invoice
customer_id Customer ID
customer_name Name of the customer who is assigned to the invoice
currency_id Currency ID
currency_code Currency code
currency_symbol Currency symbol
exchange_rate Exchange rate involved in the invoice
discount_amount Discount amount involved in the invoice
discount Discount involved in the invoice
shipping_charge Shipping charge entered in the invoice
adjustment Adjustments
sub_total Sub total of the invoice
tax_total Total tax amount in the invoice
total Total amount
balance Balance
price_precision Number of Decimal places
billing_address Billing address of the customer
shipping_address Shipping address of the customer
notes Notes
terms Terms and conditions
custom_fields Invoice custom fields
salesperson_id ID of the salesperson

Sample map:

{
	"total": "0.0",
	"payment_terms": "0",
	"terms": “Checking”,
	"price_precision": "2",
	"payment_expected_date": "2016-06-31”,
	"date": "2016-06-30",
	"shipping_address": {
		"zip": "94588",
		"country": "USA",
		"address": "4910 Hopyard Rd",
		"city": "Pleasanton",
		"state": "CA",
		"fax": "Fax Number"
	},
	"balance": "0.0",
	"adjustment": "0.0",
	"currency_symbol": "Rs.",
	"salesperson_id": “7605000000336089”,
	"currency_code": "INR",
	"shipping_charge": "0.0",
	"custom_fields": [
		{
			"customfield_id": "7605000000336081",
			"is_active": true,
			"show_in_all_pdf": false,
			"value_formatted": "INV-8",
			"data_type": "autonumber",
			"index": 1,
			"label": "AutoNumber",
			"show_on_pdf": false,
			"value": "INV-8"
		},
		{
			"customfield_id": "7605000000351027",
			"is_active": true,
			"show_in_all_pdf": true,
			"value_formatted": "01 Aug 2016",
			"data_type": "date",
			"index": 2,
			"label": "Date",
			"show_on_pdf": true,
			"value": "2016-08-01"
		}
	],
	"currency_id": "7605000000000099",
	"exchange_rate": "1.0",
	"status": "draft",
	"sub_total": "12000.0",
	"customer_name": “Customer”,
	"invoice_number": "INV-000087",
	"discount_amount": "12000.0",
	"discount": "100.00%",
	"tax_total": "0.0",
	"reference_number": “checking”,
	"due_date": "2016-06-30",
	"invoice_id": "7605000000369043",
	"notes": "Thanks for your business.",
	"customer_id": "7605000000258011",
	"billing_address": {
		"zip": "94588",
		"country": "USA",
		"address": "4910 Hopyard Rd",
		"city": "Pleasanton",
		"state": "CA",
		"fax": "Fax Number"
	}
}

Customer

The customer map supports the following fields:

Key Fields Description
owner_id ID of associated owner
billing_address Billing address associated to customer
source Source of the customer
contact_id Contact ID
payment_terms Payments terms associated to customer
currency_code Currency code
language_code Language code
contact_type Type of the contact
twitter Twitter info
zcrm_contact_id ID of the contact in Zoho CRM
shipping_address Shipping address associated to customer
pricebook_id ID of pricebook associated
contact_name Name of contact
website Website of contact
owner_name Name of contact owner
currency_symbol Currency symbol
zcrm_account_id ID of Zoho CRM account
custom_fields Custom fields associated with customer
facebook Facebook info
pricebook_name Name of pricebook associated
primary_contact_id ID of orimary contact
company_name Name of the company
contact_salutation Contact salutation
crm_owner_id ID of CRM owner
currency_id Currency ID
payment_terms_label Payment terms label
status Status

Sample map:

{
	"owner_id": "",
	"shipping_address": {
		"zip": "94588",
		"country": "USA",
		"address": "4910 Hopyard Rd",
		"city": "Pleasanton",
		"state": "CA",
		"fax": "Fax Number"
	},
	"source": "user",
	"contact_id": "7605000000197147",
	"payment_terms": "0",
	"currency_code": "INR",
	"language_code": "en",
	"contact_type": "customer",
	"twitter": "",
	"zcrm_contact_id": "",
	"billing_address": {
		"zip": "94588",
		"country": "USA",
		"address": "4910 Hopyard Rd",
		"city": "Pleasanton",
		"state": "CA",
		"fax": "Fax Number"
	},
	"pricebook_id": "",
	"contact_name": "Arun",
	"website": "www.zoho.com",
	"owner_name": "",
	"currency_symbol": "Rs.",
	"zcrm_account_id": "418070000000135001",
	"custom_fields": [
		{
			"customfield_id": "7605000000063049",
			"is_active": true,
			"show_in_all_pdf": false,
			"value_formatted": "1234",
			"data_type": "number",
			"index": 1,
			"label": "Unpaid Invoices",
			"show_on_pdf": false,
			"value": "1234"
		}
	],
	"facebook": "",
	"pricebook_name": "",
	"primary_contact_id": "7605000000197149",
	"company_name": "Zoho",
	"contact_salutation": "",
	"crm_owner_id": "",
	"currency_id": "7605000000000099",
	"payment_terms_label": "Due on Receipt",
	"status": "active"
}

Expense

The expense map supports the following fields:

Key Fields Description
date Date
payment_mode Mode of payment
custom_fields Expense custom fields
is_billable Billability of the expense
line_items Line items in the expense
project_name Name of the project involved
reference_number Reference number of the expense
currency_code Currency code
total Total
project_id ID of the project involved
sub_total Sub-total on the expense
customer_name Name if the customer involved
customer_id ID of the customer involved
expense_id Expense ID
currency_id Currency ID

Sample map:

{
	"date": "2016-10-08",
	"payment_mode": "Cash",
	"custom_fields": "[]",
	"is_billable": "true",
	"line_items": [{"tags":[],"tax_name":"Standard Rate","item_order":1,"tax_type":"tax","account_id":"348960000000000400","description":"Notes","tax_amount":16.67,"product_type":"goods","tax_id":"348960000000044037","line_item_id":"348960000000184015","tax_percentage":20,"item_total":83.33,"account_name":"Office Supplies"}],
	"project_name": "",
	"reference_number": "12345",
	"currency_code": "GBP",
	"total": "100.0",
	"project_id": "",
	"sub_total": "83.33",
	"customer_name": "Accounts",
	"customer_id": "348960000000111017",
	"expense_id": "348960000000184003",
	"currency_id": "348960000000000103"
}

Item

The item map supports the following fields:

Key Fields Description
item_id Item ID
custom_fields Item custom fields
tax_name Name of the tax involved
zcrm_product_id ID of the product in Zoho CRM
tax_id ID of the tax involved
unit Unit of the item
account_id Sales account ID
tax_type Type of the tax involved
rate Sales rate of the item
account_name Name of the sales account involved
name Name of the item
tax_percentage Percentage of tax involved
pricebook_rate Pricebook rate
sku SKU of the item
status Status of the item

Sample map:

{
	"item_id": "348960000000051011",
	"custom_fields": [{"value_formatted":"100","index":1,"is_active":true,"data_type":"decimal","show_on_pdf":true,"value":100,"show_in_all_pdf":true,"label":"Profit","customfield_id":"348960000000134003"}],
	"tax_name": "",
	"zcrm_product_id": "1665395000000205001",
	"tax_id": "",
	"unit": "1",
	"account_id": "348960000000000388",
	"tax_type": "",
	"rate": "1000.0",
	"account_name": "Sales",
	"name": "Item",
	"tax_percentage": "0",
	"pricebook_rate": "1000.0",
	"sku": "SKU",
	"status": "active"
}

A few example explaining how these fields would help in fetching the necessary paramters:

Example 1:

To fetch quote id, use:

quoteid = quote.get("quote_id");

Example 2:

To fetch your organization name, use:

orgid = organization.get("name");

Example 3:

To fetch a user’s name and ZUID, use:

username = user.get("name");
zuid = user.get("zuid");

To know more about how to use Deluge scripts for writing custom functions, refer the Deluge Reference Guide.

To know more about different scenarios where custom functions could be useful, refer our Custom Function Scenarios page.


In-App Notifications

The In-app Notification feature allows you to automatically send notifications to the users within your organization regarding a specific action. The notification can be sent either once or every time an action is carried out.

You can create an in-app notification and set up the workflow in such a way that, every time a particular action occurs, the workflow gets carried out and the in-app notification flashes within the product.

To create an in-app notification,

This is how the notification appears within the product.


Schedules

Zoho Billing lets you create and run predefined tasks at the specified time intervals using Schedules. You can create your tasks using a deluge script and schedule this task to be executed at a particular time or on a recurring basis.

Note: This feature is available only for the users in the Premium Plan (India) and Professional Plan (all other editions) of Zoho Billing.

Scenarios

Here are a few scenarios where schedules can be created to execute custom actions. However, you can create schedules based on your firm’s requirements.

Scenario 1: Peter runs a supermarket. At the end of every month, he wants to give a 10% off on the Next Purchase to customers whose total purchase for the month exceeds a certain amount, let’s say 1000. Peter creates a schedule to email this to selective customers on the last day of the month.

Scenario 2: Peter uses a third party application for maintaining customer and employee database internally. He would like to sync all data from Zoho Billing to the other application periodically. To do so, he creates a custom schedule to sync the data at 6 pm every day.

Scenario 3: Peter sets a quarterly sales target for his territorial managers. Every four months, he has to send them their Profit and Loss reports and a congratulatory email when they have achieved their target or a motivating email for them to perform better. He writes a function and schedules it to be sent to his staff once every 4 months.

Creating New Schedules

To create a new schedule:

Sample Function:

Here’s a sample function for Scenario 1:

organizationID = organization.get("organization_id");
name = organization.get("name");
orgEmail = organization.get("email");
salesResponse = invokeUrl
 [
 url: "https://billing.zoho.com/api/v3/reports/salesbycustomer?organization_id=" + organizationID + "&from_date=" + toStartOfMonth(today).toString("YYYY-MM-dd") + "&to_date=" + eomonth(today,0).toString("YYYY-MM-dd")
 type: GET
 connection: "billing_api_connection"
 ];
salesDetails = salesResponse.get("sales").toList();

for each  sales in salesDetails
{
	amount = sales.get("sales_with_tax");
	if(amount > "<ENTER AMOUNT>")
	{
		customerName = sales.get("customer_name");
    customerResponse = invokeUrl
     [
     url: "https://billing.zoho.com/api/v3/customers/" + sales.get("customer_id") + "?organization_id=" + organizationID
     type: GET
     connection: "billing_api_connection"
     ];
    customerDetails = customerResponse.get("contact");
		customerEmail = customerDetails.get("email");
		sendmail
		[
			from :zoho.adminuserid
			to :customerEmail
			subject :"Thank you for shopping! Here's a 10% discount!"
			message :"<div>Dear&nbsp;" + customerName + ",<br></div><div><br></div><div>We just wanted to take a moment of our time to thank you for your continuous support.<br></div><div><br></div><div> Based on your recent purchases, we'd like to offer you a 10% off on your next purchase with us.&nbsp;<br></div><div><br></div><div>Please show this email during billing to avail this discount!<br></div><div><br></div><div>Regards,<br></div><div>" + name + "<br></div><div><br></div><div><br></div><div><br></div><div><br></div>"
		]
	}
}

Was this document helpful?
Yes
No
Thank you for your feedback!