Update Records in Zoho Subscriptions

 Overview

Using zoho.subscriptions.update() Deluge task in Zoho Creator, you can update records in supported modules of Zoho Subscriptions. You can make use of different workflow options in Zoho Creator to automate this process . Update customer details and subscription details of customers as and when you need to, using this task. For example, you can execute "form actions" in Zoho Creator to update a customer's contact information or modify his subscription details. 

 Supported Modules

  • Customers
  • Subscriptions

 Syntax

<response> = zoho.subscriptions.update(<module>, <orgID>, <ID>, <params>);

where,
<response> is the map variable returned as response. It contains the details of the updated record. 
<module> is the name of the Zoho Subscriptions Module from where the record needs to be fetched. For example, "Customers" refers to the Customers module.
<orgID> refers to your organization ID as specified in Zoho Subscriptions. To know your organization ID, click on <YourOrganizationName> > Manage Organizations, from the top-right corner of your Zoho Subscriptions Home page. Click here to learn more about Org ID.
<ID> refers to the ID of the record that needs to be updated
<params> is the map variable that holds the key,value pairs. The map key is the label name as specified in the Zoho Subscriptions module and the map value is the field value as submitted in the ZC form. For example, "display_name" : input.Customer_Name . Here, "display_name" is the label name as specified in the Zoho Subscriptions module and "input.Customer_Name" refers to the value specified in the Contact_Name field in the Zoho Creator form.

Note:

  • All the parameters listed above are mandatory. 

 Examples

1) Update transaction details in Zoho Subscriptions using Zoho Creator form

In this example, we will update subscription details by adding code to a Zoho Creator form and submitting the form. The form consists of a field "Plan Code". Upon submission of the form, the subscription details of the specified record gets updated using the data submitted.

  • Add the following scipt in the "on Success" section of your Zoho Creator form

params = map();
para = map();
para.put("plan_code", input.Plan_Code);
params.put("plan", para);
response = zoho.subscriptions.update("subscriptions", "12345678", "3808000000040107", params);

  • Submitting the form updates the subscription plan according to the submitted value.

where, 
"input.Plan_Code" refers to Zoho Creator form field.

 Response Format

Following is the response format returned by Zoho Subscriptions to Zoho Creator:

{
"message":"Subscription has been updated successfully.",
"subscription":{
"subscription_id":"115888000000047005",
"payment_terms":0,
"interval":1,
"product_id":"115888000000037018",
"payment_terms_label":"Due on Receipt",
"next_billing_at":"2015-04-10",
"product_name":"zoho",
"current_term_starts_at":"2015-03-10",
"customer":{
"payment_terms":0,
"payment_terms_label":"",
"zcrm_account_id":"",
"shipping_address":{
"zip":"",
"fax":"",
"street":"",
"state":"",
"country":"",
"city":""
},
"first_name":"",
"display_name":"ram",
"email":"ram.s@gmail.com",
"company_name":"",
"zcrm_contact_id":"",
"last_name":"",
"customer_id":"115888000000046001",
"billing_address":{
"zip":"",
"fax":"",
"street":"",
"state":"",
"country":"",
"city":""
}
},
"interval_unit":"months",
"updated_time":"2015-03-10T11:06:10+0530",
"current_term_ends_at":"2015-04-10",
"amount":1000,
"salesperson_name":"",
"name":"zoho-monthly",
"reference_id":"",
"salesperson_id":"",
"currency_symbol":"Rs.",
"activated_at":"2015-03-10",
"currency_code":"INR",
"custom_fields":"[]",
"child_invoice_id":"115888000000046015",
"status":"live",
"addons":"[]",
"last_billing_at":"2015-03-10",
"contactpersons":[
{
"phone":"",
"email":"ram.s@gmail.com",
"zcrm_contact_id":"",
"contactperson_id":"115888000000046003",
"mobile":""
}
],
"expires_at":"",
"plan":{
"tax_name":"",
"setup_fee":0,
"price":1000,
"tax_type":"",
"name":"monthly",
"tax_id":"",
"quantity":1,
"tax_percentage":"",
"plan_code":"monthly"
},
"created_time":"2015-03-10T11:00:18+0530",
"taxes":"[]",
"auto_collect":false
},
"code":0
}

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

Error Response for - No records updated

{"message":"The actions is not allowed for this profile as there are no changes made in the plan or addons.","code":26005}