Create Records in SkyDesk CRM

Overview

SkyDesk Creator and SkyDesk CRM have been integrated for efficient usability purposes. We have developed integration tasks in SkyDesk Creator to perform automatic actions in SkyDesk CRM, which would otherwise require manual execution. Lets take the example of creating records. You can add a record in SkyDesk Creator form(by submitting the form) and have it simultaneously added in SkyDesk CRM without re-entering data for the second time in CRM. This can be achieved by using zoho.crm.create() task in SkyDesk Creator.

Use Case Scenario

Let's say we have a SkyDesk Creator sign-up form which is submitted by users to initiate their interest/probe for a particular product. To create a Lead simultaneously in our SkyDesk CRM’s "Leads" module, you can execute zoho.crm.create() task in the "On Success" form actions block of the Creator form. This will create a record in SkyDesk CRM with relevant details whenever the form is submitted. Further details on how to execute this task are explained below.

Syntax

<variable>=zoho.crm.create(<module_name>,<field_values>,[<duplicate_check>]);

where,

Params  Description

<variable> 

is the response returned as MAP by SkyDesk CRM.

<module_name> 

is the name of the CRM module, of STRING datatype, where the record will be added. For example, "Leads" refers to the Leads module. Following is the list of supported modules.

Leads

Potentials

Products

Contacts

Campaigns

Vendors

Accounts

Cases

Quotes

Sales Orders

Purchase Orders

Invoices

<field_values>

is the MAP variable that holds the key,value pairs. The map key is the label name as specified in the CRM module and the map value is the field value as submitted in the ZC form.

For example, "Company" : input.Company_Name . Here, "Company" is the label name as specified in the CRM module and input.Company_Name refers to the value specified in the Company_Name field in the SkyDesk Creator form.

<duplicate_check>

     (optional)

is of NUMBER datatype. The following table represents the duplicate check values and it's description.

Value Description

1

Checks for duplicate records in CRM and throws an error response, if found.

2

Checks for duplicate records in CRM and updates the same, if found.

0

Duplicate check is not peformed.

Example 1: Creating a Lead in SkyDesk CRM

Let’s take an example of creating a Lead in SkyDesk CRM by submitting a form in SkyDesk Creator. Assume we have a Creator form, containing fields:

  • Name (Single Line field type)
  • Company Name (Single Line field type)
  • Phone (Number field type)
  • Email Address (Email field type)
  • PO Box (Number field type)
  • Country (Single Line field type)

The form is used to record details of a potential customer who is interested in buying a product. To create this record simultaneously in SkyDesk CRM LEAD module, add the following script in the On Add -> On Success block of the form.

leadinfo = {"Company":input.Company_Name,"Last Name":input.Last_Name,"Phone":input.Phone,"Email":input.Email_Address,"PO Box":input.PO_Box,"Country":input.Country};

 

response = zoho.crm.create("Leads",leadinfo);

where,

leadinfo
is a map variable that holds the key value pairs.
"Company" 
"Last Name" 
"Phone" 
"Email" 
"PO Box" 
"Country"
are SkyDesk CRM field labels of string type. 
input.Company_Name 
input.Name 
input.Telephone 
input.Email_Address 
input.PO_Box 
input.Country
are SkyDesk Creator field inputs.
"Leads"
is the CRM module, of  string type, where the record will be created.
response
is response returned as map by SkyDesk CRM. Check sample response here.

Note: The following modules follow a similar process of creating records, as explained in the above example:

  • Leads
  • Potentials
  • Products
  • Accounts
  • Contacts
  • Campaigns
  • Vendors
  • Cases

Example 2: Creating a Quote with Account Name, Products list and Subject

Let’s take an example of creating a Quote (containing Account Name, Products list and Subject) in SkyDesk CRM, by submitting a form in SkyDesk Creator. Assume we have a SkyDesk Creator form with fields:

  • CRM Account (SkyDesk CRM Accounts field type)
  • Subject (Single Line field type)
  • Product Details (Subform field type) containing CRM Product (SkyDesk CRM Products field type) and Quantity (Number field type) fields.

While submitting the form, to create the quote simultaneously in SkyDesk CRM Quotes module, add the following script in On Add > On Success block of the Creator Form and click on Save.

quoteDetails=Map(); 
quoteDetails.put("Subject",input.Subject_field); 
quoteDetails.put("ACCOUNTID",input.CRM_ACCOUNT_ID);productsList=List:Map(); 
for eachproductininput.Product_Details 
{ 
      productDetails=Map(); 
      productDetails.put("Product Id",product.CRM_PRODUCT_ID); 
      productDetails.put("Quantity",product.Quantity); 
      productsList.add(productDetails); 
} 
quoteDetails.put("Products",productsList);
response=zoho.crm.create("Quotes",quoteDetails);

where,

quoteDetails 
productDetails
are map variables that hold the key value pairs.
"Subject" 
"ACCOUNTID" 
"Product Id" 
"Quantity" 
"Products"
are SkyDesk CRM field labels of string type.
input.Subject_field 
input.CRM_ACCOUNT_ID 
input.Email_Address
are SkyDesk Creator field inputs.
input.Product_Details
is Subform field input.
product
stands for each subform entry or record.
product.CRM_Product_ID 
product.Quantity
are unique Subform field inputs for each Subform entry or record.
productsList
is a list variable containing map values of subform field inputs.
"Quotes"
is the CRM module, of  string type, where the record will be created.
response
is response returned as map by SkyDesk CRM. Check sample response here.

Note: The following modules follow a similar process of creating records, as explained in the above example:

  • Quotes
  • Sales Orders
  • Purchase Orders
  • Invoices

Example 3: Upload an attachment to SkyDesk CRM

Let's say we have a SkyDesk Creator form to store Leads which contains, among other field types, a file-upload field type. The label name for attachment in CRM is Attachment in both syntax and response. To upload an attachment in CRM, the following script can be added to On Add > On Success block.

leadinfo={"Company":input.Company,"Last Name":input.Name,"Email":input.Email,"Attachment":input.File_upload};

 

response=zoho.crm.create("Leads",leadinfo);

where,

leadinfo
is a map variable that holds the key value pairs.
"Company" 
"Last Name" 
"Email" 
"Attachment"
are SkyDesk CRM field labels of string type. 
input.Company 
input.Name 
input.Email 
input.File_upload
are SkyDesk Creator field inputs.
"Leads"
is the CRM module, of  string type, where the record containing the attachment
will be created.
response
is response returned as map by SkyDesk CRM. Check sample response here.

Example 4: Create a Task in CRM with Contact and Account lookup

Let's assume we have a SkyDesk Creator Form with the following fields:

  • Owner Name (Single Line field type)
  • Owner ID (Number field type)
  • Subject (Single Line field type)
  • Description (Multi Line field type)
  • CRM Account (SkyDesk CRMAccounts field type)
  • CRM Contact (SkyDesk CRM Contacts field type)

To create a Task in CRM, add the following script in the On Add > On Success block of the form:

taskInfo={"Task Owner":input.Owner_Name,"Subject":input.Subject,"Description":input.Description,"SEMODULE":"Accounts","SEID":input.CRM_Account_ID,"CONTACTID":input.CRM_Contact_ID};

response=zoho.crm.create("Tasks",taskInfo);

where,

taskinfo
is a map variable that holds the key value pairs.
"Task Owner" 
"Subject" 
"Description" 
"SEMODULE" 
"SEID" 
"CONTACTID"
are SkyDesk CRM field labels of string type. 
input.Owner_Name 
input.Subject 
input.Description 
input.CRM_Account_ID 
input.CRM_Contact_ID
are SkyDesk Creator field inputs.
"Accounts"
stands for the module, of  string type, to which the task will be attached. In this
case it is "Accounts". 
"Tasks"
is the CRM module, of  string type, where the record will be created.
response
is response returned as map by SkyDesk CRM. Check sample response here.

Example 5 : Adding notes to a Lead

Let's say we have a Creator form with the following fields:

  • CRM Lead (SkyDesk CRM Leads field type)
  • Note Title (Single Line field type)
  • Note Description (Multi Line field type)

Add the following script in the On Add > On Success block of the form to attach Notes to the specified lead:

notesMap={"entityId":input.SkyDesk_Lead_ID,"Note Title":input.Note_Title,"Note Content":input.Note_Description};

 

response=zoho.crm.create("Notes",notesMap);

where,

notesMap
is a map variable that holds the key value pairs.
"entityId" 
"Note Title" 
"Note Content"
are SkyDesk CRM field labels of string type. 
input.SkyDesk_Lead_ID 
input.Note_title 
input.Note_Description
are SkyDesk Creator field inputs.
"Notes"
is the CRM module, of  string type, where the record will be created.
response
is response returned as map by SkyDesk CRM. Check sample response here.

Example 6 : Create an Event

Let's assume we have a SkyDesk Creator Form with the following fields:

  • Subject (Single Line field type)
  • Event StartTime (Date-Time field type)
  • Event EndTime (Date-Time field type)

To create a record in the Events module with the Form input values, add the following script in On Add > On Success section of the form:

eventinfo={"Subject":input.Subject,"Start DateTime":input.Event_StartTime,"End DateTime":input.Event_EndTime };

 

response=zoho.crm.create("Events",eventinfo);

where,

eventinfo
is a  map  variable that holds key value pairs.
"Subject" 
"Start Date Time" 
"End Date Time"
are SkyDesk CRM field labels of string type. 
input.Subject 
input.Event_StartTime 
input.Event_EndTime
are SkyDesk Creator field inputs
"Events"
is SkyDesk CRM module of  string type. 
response
is response returned as  map by SkyDesk CRM. Check sample response  here.

Note: The date-time values selected in SkyDesk Creator are rendered the same in SkyDesk CRM irrespective of their configured date-time formats.

Example 7 : Create records in a Custom Module

Assume we have a SkyDesk Creator Form and a Custom Module in SkyDesk CRM, both consisting of the following fields:

  • Name (Single Line field type)
  • Phone(Number field type)
  • Email (Email field type)

To create a record in a Custom Module with the Form input values, add the following script in On Add > On Success section of the form:

custominfo={"Name":input.Name,"Phone":input.Phone,"Email":input.Email };

 

response=zoho.crm.create("CustomModule1",custominfo);

where,

custominfo
is a  map variable that holds the key value pairs.
"Name" 
"Phone" 
"Email"
are SkyDesk CRM field labels of string type. 
input.Name 
input.Phone 
input.Email
are SkyDesk Creator field inputs
"CustomModule1"
is the label name of SkyDesk CRM Custom Module, of string type. The URL
of SkyDesk CRM Custom Module can be used to retrieve the Custom Module label name.
For example - https://crm.skydesk.jp/crm/CreateEntity.do?module= CustomModule1
response
is response returned as  map by SkyDesk CRM. Check sample response  here.

Note: Custom Modules are by default named as CustomModuleX (where X is a number). Specify the same Custom Module name format in the syntax. The URL of SkyDesk CRM Custom Module can be used to retrieve the Custom Module label name. For example - https://crm.skydesk.jp/crm/CreateEntity.do?module=CustomModule1

Response Format

The response returned is of the following format:

{
    
"message":"Record(s) added successfully",
    "Created Time":"2011-06-14 12:28:11",
    "Modified By":"SkyDeskTest",
    "Id":"1584000000028003",

    "Modified Time":"2011-06-14 12:28:11",
     "Created By":"SkyDeskTest"

}

 

To get the ID of the newly created record, execute the following script:

currentid=response.get("Id").toLong();

 

If record creation fails due to any reason, a failure response of the following format is returned. To know more about error codes, click here.

{
    
"message":"No CRM account",
     "code":"4102"

}

Limitation

CRM Tasks can be executed only in accounts which are under Flexible and Unlimited Plans. Accounts under Free Plan, kindly upgrade to use CRM tasks. For more details scroll down to Integration and Web Data on the pricing page.

Script Builder

You can also make use of Script builder to define the zoho.crm.create() task. Navigate to your application’s Workflow and drag and drop the Call Function under Deluge Tasks > Miscellaneous. Select Integration tasks and fill out necessary information.

Related Links

  • To fetch the string value to which the specified key is mapped, use get()
  • To get values from fetched records, use getJSON()