Create record in Zoho Invoice
Table of Contents
Overview
This task is used to create a record in Zoho Invoice.
Syntax
<variable> = zoho.invoice.create(<module_name>, <org_ID>, <data_map>, <connection>);
where,
Parameter | Data type | Description | ||||||||
<variable> | KEY-VALUE | specifies the variable which will hold the response returned by Zoho Invoice. | ||||||||
<module_name> | TEXT | specifies the Zoho Invoice's module in which the record will be created. Following are the applicable modules.
| ||||||||
<org_ID> | TEXT | specifies the organization ID of the account in which the record will be created. | ||||||||
<data_map> | KEY-VALUE | Input map with key as Invoice field's name and the required value. To learn about the mandatory fields, click here and go to <ModuleName> -> Create <ModuleName> | ||||||||
<connection>* (optional) | TEXT | specifies the name of the Zoho Invoice connection. *Note: This param is not supported when used in Zoho Creator. |
Examples
1) Let's say we have a Zoho Creator form containing a field called Customer_ID, and a subform called Products. The subform contains fields item_id, name, rate, and quantity. On submission of this form, an invoice must be created in Zoho Invoice with the details specified in the subform. We can achieve this using the following snippet:
listVar = List(); //iterating each row in the subform for each line in Products { mapVar = map(); mapVar.put("item_id", line.item_id); mapVar.put("name", line.name); mapVar.put("rate", line.rate); mapVar.put("quantity", line.quantity); listVar.add(mapVar); } values = map(); values.put("customer_id", input.Customer_ID); values.put("line_items", listVar); response = zoho.invoice.create("Invoices", "66XXXXX66", values);
where,
listVar
mapVar values
"item_id" "name" "rate" "quantity" "customer_id" "line_items"
"Invoices"
"66XXXXX66"
2) The following script creates a new record in the Zoho Invoice module - customerpayments.
CusPayMap=map(); CusPayMap.put("customer_id","13144XXXXXXXXXXXX"); CusPayMap.put("payment_mode","cheque"); CusPayMap.put("amount","450"); CusPayMap.put("date","2017-01-01"); response =zoho.invoice.create("Customerpayments", "5368XXXX",CusPayMap);
where,
CusPayMap
"customer_id" "payment_mode" "amount" "date"
"Customerpayments"
"5368XXXX"
Sample Response
Success Format
The following is a sample success response:
{
"payment":{
"date":"2017-01-01",
"can_send_in_mail":true,
"documents":[],
"discount_amount":0.0,
"is_payment_details_required":true,
"attachment_name":"",
"is_client_review_settings_enabled":false,
"description":"",
"currency_code":"INR",
"online_transaction_id":"",
"page_width":"8.27in",
"bank_charges":0.0,
"invoices":[],
"payment_id":"13144XXXXXXXXXXXX",
"tax_amount_withheld":0.0,
"custom_field_hash":{},
"template_type":"elite",
"product_description":"",
"last_four_digits":"",
"payment_mode":"check",
"amount":450.0,
"orientation":"portrait",
"exchange_rate":1.0,
"custom_fields":[],
"payment_refunds":[],
"card_type":"",
"reference_number":"",
"template_name":"Elite Template",
"template_id":"13144XXXXXXXXXXXX",
"customer_name":"Bowman and Cos",
"unused_amount":450.0,
"customer_id":"13144XXXXXXXXXXXX",
"is_pre_gst":true,
"currency_id":"13144XXXXXXXXXXXX",
"page_height":"11.69in"
},
"code":0,
"instrumentation":{
"response_write_time":11,
"query_execution_time":28,
"page_context_write_time":0,
"request_handling_time":1012
},
"message":"The payment from the customer has been recorded"
}
To get the ID of the newly created record, execute the following script:
// example for <module_name> is contact and example for <module_name>_id is contact_id
Failure Response
The failure response returned due to incorrect organization ID is of the following format:
{
"code":6041,
"message":"This user is not associated with the CompanyID/CompanyName:537XX."
}