Create Records

Create record in Zoho Subscriptions

Overview

This task is used to create a record in Zoho Subscriptions.

Syntax

<variable> = zoho.subscriptions.create(<module_name><org_id>,<data_map>, <connection>);

where,

ParameterData typeDescription

<variable> 

KEY-VALUE

is the variable response returned by Zoho Subscriptions.

<module_name> 

TEXT

is the name of the module in where the record will be added.

Following are the applicable modules.

Subscriptions

Customer

Hosted Pages

Products

<org_id>TEXT

Org ID of the organization in which the record will be created.c

Note: Learn how to fetch organization ID from the UI and from the response of zoho.subscription.getOrganization task.

<data_map>

KEY-VALUE

Input map with key as Zoho Subscriptions field's name and the required value. For ex: {"display_name":input.Last_Name}

To learn about the mandatory fields, click here and go to <Module> --> Create <Module> 

<connection>

(optional)

TEXT

specifies the name of the Zoho Subscriptions connection.

*Note: This param is not applicable in Zoho Creator and mandatory in Zoho Cliq.

Examples

1) Let's say we have a Zoho Creator form containing fields Customer_ID, and Plan code. On submission of this form, a subscription must be created in Zoho Subscriptions with the details specified in the form. We can achieve this using the following snippet:

values = map();
values.put("customer_id", input.Customer_ID);
values.put("auto_collect", false);
values.put("plan", {"plan_code" : input.Plan_Code});

response = zoho.subscriptions.create("Subscriptions", "66XXXXX66", values);

where,

 values
is a MAP variable which hold key value pairs required to create a subscription
 "auto_collect"
 "plan"
 "plan_code"
 "customer_id"
are the TEXT that represents the label name of the field specified in Zoho Subscriptions API. Customer ID can be viewed in the url in Zoho Subscriptions when you click on a Customer record.
"Subscriptions"
is the TEXT that represents the module in which the record needs to be created
"66XXXXX66"
is the TEXT that represents the organization ID of the Zoho Subscriptions account in which the record needs to be created

2) Let’s take an example of creating a record in the "Customers" module in Zoho Subscriptions using the following snippet.

values = map();
values.put("display_name" , "john");
values.put("email" , "john@zylker.com");

resp = zoho.subscriptions.create("Customers", "10982991", values);

where,

ParameterDescription
valuesis a map variable that holds key value pairs
"display_name"
"email"
are names of Zoho Subscriptions fields.
john
john@zylker.com
are field inputs
"Customers"is the module in Zoho Subscriptions, where the record will be created.
respis response returned as map by Zoho Subscriptions.
10982991org id of the organzation in which the record will be created.

Sample Response

The following is a sample success response:

{  
   "message":"The customer has been added.",
   "code":0,
   "customer":{  
      "default_templates":{  
         "creditnote_template_id":"",
         "invoice_template_id":""
      },
      "phone":"",
      "payment_terms":0,
      "payment_terms_label":"Due On Receipt",
      "price_precision":2,
      "updated_time":"2015-03-10",
      "outstanding_receivable_amount":0,
      "shipping_address":{  
         "zip":"",
         "fax":"",
         "street":"",
         "state":"",
         "country":"",
         "city":""
      },
      "first_name":"",
      "company_name":"",
      "zcrm_contact_id":"",
      "currency_symbol":"Rs.",
      "outstanding":0,
      "currency_code":"INR",
      "custom_fields":"[]",
      "currency_id":"115888000000000099",
      "status":"active",
      "pricebook_id":"115888000000011001",
      "zcrm_account_id":"",
      "unused_credits":0,
      "display_name":"zoho",
      "email":"zohocorp@gmail.com",
      "last_name":"",
      "created_time":"2015-03-10",
      "notes":"",
      "customer_id":"115888000000046001",
      "mobile":"",
      "billing_address":{  
         "zip":"",
         "fax":"",
         "street":"",
         "state":"",
         "country":"",
         "city":""
      }
   }
}

To fetch the ID of the record from the returned response, use the following snippet:

info <response_variable>.get("<module_name>").get("<module_name>_id">
// example for <module_name> is customer and example for <module_name>_id is customer_id

The following is a sample failure response:

{
"message":"Enter valid Customer Name",
"code":3013
}

Related Links

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohodeluge.com