Create a record in QuickBooks

Table of Contentsup

 Overview

The intuit.quickbooks.create() task is used to add a record in any of the supported modules of your QuickBooks account, directly from your Zoho Creator Application.  For example, you can add a new customer, create a new invoice for a specific customer or add a new vendor in quickbooks.  To connect Zoho Creator with QuickBooks, create a new connection from the Setup - Connections page. 

 Supported Modules

  • Customer
  • Vendor
  • Item
  • Invoice
  • Account
  • Employee
  • Department

 Syntax

<quickbooksResponse> = intuit.quickbooks.create(<quickbooksConnectionName>,<quickbooksModuleName>,<quickbooks CompanyId> , <params>);

where, 
<quickbooksResponse> is the map variable returned as response. It contains the details of the newly created record. 
<quickbooksConnectionName> refers to the connection name used to connect Zoho Creator with Quickbooks. Create a new connection from the Setup - Connections page. 
<quickbooksModuleName> refers to the module name in Quick Books where the record is created.
<quickbooksCompanyId> refers to the unique ID generated by Quickbooks for each account. You can find this under Your Company -> Account and Settings -> Billing & Subscription -> Company Id in your Quickbooks account.
<params> is the map variable that holds the key,value pairs. The map key is the label name in the format as specified in QuickBooks API. The map value is the field value as submitted from a Zoho Creator application. Refer the Quickboks API Guide for the attributes to be specified for each module.

 Example - To create a record

A sample script to add a customer to the Quickbooks customer module is given below. You can execute this script from a Zoho Creator form by adding it to the required Form Actions block.  For example, to add a record to the customer module, based on the values submitted from a Zoho Creator form,  

  1. Select the Form from your Dashboard page
  2. Click on Settings - On Add - Actions on Success
  3. Add the script to the editor area. 
  4. Click on Save Script to save the script definition.

//Declare Map Variable to hold the customer details
Customer_Details = map();

//Add the customer details to the map variable

Customer_Details.put("FamilyName", "George Stepenson");
Customer_Details.put("FullyQualifiedName", "Stepenson ");
Customer_Details.put("DisplayName", "George");

//declare map variable to hold the shipping address
Shipping_Address = map();

//add shipping address to the map variable
Shipping_Address.put("Line1", "312, 10th Avenue");
Shipping_Address.put("Line2", "Rick cross street");
Shipping_Address.put("Line3", "5th Block");
Shipping_Address.put("Country", "USA");

//declare map variable to hold the billing address
Billing_Address = map();

//add billing address to the map variable 
Billing_Address.put("Line1", "312, 10th Avenue");
Billing_Address.put("Line2", "Rick cross street");
Billing_Address.put("Line3", "5th Block");
Billing_Address.put("Country", "USA");

//adding the shipping address to customer details
Customer_Details.put("ShipAddr", Shipping_Address);

//adding the billing address to customer details
Customer_Details.put("BillAddr", Billing_Address);

//creating the customer in the Quickbooks Customer module with connecton name "Zoho" and account id "1241802285"
createResponse = intuit.quickbooks.create("Zoho", "Customer", "1241802285", Customer_Details);
 

 Example - To get the ID of the created record

createResponse = createResponse.get("Customer");
id = createResponse.get("Id");

info id ;

Note

  • You can add the script directly to the editor area by selecting Free-flow scripting link displayed on the top-right corner of the script builder ( or ) use the drag-and-drop functionality in Script Builder.
  • In the above example, we have specified the param values directly within quotes. To fetch the param values from a Zoho Creator form, specify the field name used in the form. For example, if Family_Name is the Field Deluge name, the key value pair should be specified in the following format: ("FamilyName",  Family_Name)

 Response Format

The response returned by Quickbooks will be in the format given below.

{
"Customer":"{" ShipAddr":"{" Line3":"5th Block",
"Long":"-121.8773403",
"Line2":"Rick cross street",
"Line1":"312, 10th Avenue",
"Lat":"37.3357731",
"Id":"13",
"Country":"USA"
}","PreferredDeliveryMethod":"Email",
"BalanceWithJobs":0,
"DisplayName":"George",
"FullyQualifiedName":"George",
"BillWithParent":false,
"Job":false,
"Active":true,
"MetaData":"{"CreateTime":"2014-08-06T03:19:41-07:00",
"LastUpdatedTime":"2014-08-06T03:19:41-07:00"
}","Taxable":false,
"BillAddr":"{"Line3":"5th Block",
"Long":"-121.8773403",
"Line2":"Rick cross street",
"Line1":"312, 10th Avenue",
"Lat":"37.3357731",
"Id":"12",
"Country":"USA"
}","domain":"QBO",
"SyncToken":"0",
"PrintOnCheckName":"George Stepenson",
"CurrencyRef":"{"name":"Indian Rupee",
"value":"INR"
}","Id":"8",
"FamilyName":"George Stepenson",
"Balance":0,
"sparse":false
}","time":"2014-08-06T03:19:41.084-07:00"
}

If for some reason, the execution fails, the response will be in the following format.

ERROR RESPONSE - For Invalid Parameter Name

{
"Error":"[{
"Detail":"Property Name:Can not instanti specified is unsupported or invalid",
"Message":"Request has invalid or unsupported property",
"code":"2010"
}]"
}

 Using Script Builder

To add the script using the drag-n-drop functionality in Script Builder,

  1. Select the Form from your Dashboard page
  2. Click on Settings - On Add - Actions on Success
  3. Click on Script Builder from the top-right cormer of the page.
  4. Drag and drop the call function in the editor box. 
  5. Select Integration tasks
  6. Select Service as Quickbooks
  7. Select Function as Create Record.
  8. Select the Connection Name to connect with Quickbooks. Click on +Create to create a new connection or create a new connection from the Setup - Connections page
  9. Select the required Module name in Quickbooks.
  10. Specify the unique Company ID of your Quickbooks account. Refer CompanyId for more information.
  11. Select the map variable that holds the key-value pairs for the create request (or) click on "New Map" to add key-value pairs for the create request. 
  12. Specify the response variable that will hold the response returned by Quickbooks.
  13. Click on Done to insert the call function task.


Upon submission of the form, a record is added in Quickbooks to the selected module. The response variable will contain the response returned by Quickbooks. 

Note

  • The key-value pairs displayed will differ based on the module selected.