Insert Records using External ID

Purpose

To add new entities to a module using external ID. Here are a few scenarios.

Request Details

Request URL

https://www.zohoapis.com/crm/v2/{module_api_name}

Supported modules

Leads, Accounts, Contacts, Deals, Campaigns, Tasks, Cases, Events, Calls, Solutions, Products, Vendors, Price Books, Quotes, Sales Orders, Purchase Orders, Invoices, Custom, and Activities

Possible operation types

Header

Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52

X-EXTERNAL: {module_API_name}.{external_field_API_name}

Scope

scope=ZohoCRM.modules.all
(or)
scope=ZohoCRM.modules.{module_name}.{operation_type}

Possible module names

leads, accounts, contacts, deals, campaigns, tasks, cases, events, calls, solutions, products, vendors, pricebooks, quotes, salesorders, purchaseorders, invoices, custom, and notes

Possible operation types

ALL - Full access to the record
WRITE - Edit records in the module
CREATE - Create records in the module

Sample Request

Copiedcurl "https://www.zohoapis.com/crm/v2/{base_module_API_name}"
-X POST
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-H "X-EXTERNAL: {module_API_name}.{external_field_API_name}"
-d "@sample.json"
Associating a lookup record through an external field
  • In this example, Contacts is the base module's API name where Account_Name is a lookup field's API name in the Contacts module. External_Account_ID is the API name of the external field in the Accounts module. We will reference the external field's value in the Accounts module to create a record in the Contacts module.

Note

If you specify the value and the record ID of the external field for the lookup record, the system considers only the value of the external field when you give the X-EXTERNAL header. Without this header, the system considers only the record ID.

Sample Request

Copiedcurl "https://www.zohoapis.com/crm/v2/Contacts"
-X POST
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-H "X-EXTERNAL: Contacts.Account_Name.External_Account_ID"
-d "@sample.json"
3.0.0
Copied//API Name of the module to create records
String moduleAPIName = "Leads";

//Get instance of RecordOperations Class
RecordOperations recordOperations = new RecordOperations();

//Get instance of BodyWrapper Class that will contain the request body
BodyWrapper bodyWrapper = new BodyWrapper();

//List of Record instances
List < com.zoho.crm.api.record.Record > records = new ArrayList < com.zoho.crm.api.record.Record > ();

//Get instance of Record Class
com.zoho.crm.api.record.Record record1 = new com.zoho.crm.api.record.Record();

/*
 * Call addFieldValue method that takes two arguments
 * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
 * 2 -> Value
 */
//		record1.addFieldValue(Field.Leads.CITY, "City");
//		
record1.addFieldValue(Field.Leads.LAST_NAME, "Last Name");
//		
//		record1.addFieldValue(Field.Leads.FIRST_NAME, "First Name");
//		
//		record1.addFieldValue(Field.Leads.COMPANY, "KKRNP");

/*
 * Call addKeyValue method that takes two arguments
 * 1 -> A string that is the Field's API Name
 * 2 -> Value
 */
//		record1.addKeyValue("Custom_field", "Value");
//		
//		record1.addKeyValue("Custom_field_2", "value");
//		
//		record1.addKeyValue("Date_1", LocalDate.of(2021, 1, 13));
//		
//		record1.addKeyValue("Subject", "AutomatedSDK");

List < FileDetails > fileDetails = new ArrayList < FileDetails > ();

FileDetails fileDetail1 = new FileDetails();

fileDetail1.setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c32537b7c2400dadca8ff55f620c65357da");

fileDetails.add(fileDetail1);

FileDetails fileDetail2 = new FileDetails();

fileDetail2.setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c32e0063e7321b5b4ca878a934519e6cdb2");

fileDetails.add(fileDetail2);

FileDetails fileDetail3 = new FileDetails();

fileDetail3.setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c323daf4780bfe0058133556f155795981f");

fileDetails.add(fileDetail3);

record1.addKeyValue("File_Upload", fileDetails);

/** Following methods are being used only by Inventory modules */

//		com.zoho.crm.api.record.Record dealName = new com.zoho.crm.api.record.Record();
//		
//		dealName.addFieldValue(Field.Deals.ID, 3477061000004995070L);
//		
//		record1.addFieldValue(Field.Sales_Orders.DEAL_NAME, dealName);
//		
//		com.zoho.crm.api.record.Record contactName = new com.zoho.crm.api.record.Record();
//		
//		contactName.addFieldValue(Field.Contacts.ID, 3477061000004977055L);
//		
//		record1.addFieldValue(Field.Purchase_Orders.CONTACT_NAME, contactName);
//		
//		com.zoho.crm.api.record.Record accountName = new com.zoho.crm.api.record.Record();
//		
//		accountName.addKeyValue("name", "automatedAccount");
//		
//		record1.addFieldValue(Field.Quotes.ACCOUNT_NAME, accountName);
//		
//		i
//		
//		List<InventoryLineItems> inventoryLineItemList = new ArrayList<InventoryLineItems>();
//		
//		InventoryLineItems inventoryLineItem = new InventoryLineItems();
//		
//		LineItemProduct lineItemProduct = new LineItemProduct();
//		
//		lineItemProduct.setId(3477061000005356009L);
//		
//		inventoryLineItem.setProduct(lineItemProduct);
//		
//		inventoryLineItem.setQuantity(1.5);
//		
//		inventoryLineItem.setProductDescription("productDescription");
//		
//		inventoryLineItem.setListPrice(10.0);
//		
//		inventoryLineItem.setDiscount("5.0");

//		inventoryLineItem.setDiscount("5.25%");
//		
//		List<LineTax> productLineTaxes = new ArrayList<LineTax>();
//		
//		LineTax productLineTax = new LineTax();
//		
//		productLineTax.setName("Tax1");
//		
//		productLineTax.setPercentage(20.0);
//		
//		productLineTaxes.add(productLineTax);
//		
//		inventoryLineItem.setLineTax(productLineTaxes);
//		
//		inventoryLineItemList.add(inventoryLineItem);
//
//		record1.addKeyValue("Product_Details", inventoryLineItemList);
//		
//		List<LineTax> lineTaxes = new ArrayList<LineTax>();
//		
//		LineTax lineTax = new LineTax();
//		
//		lineTax.setName("Tax1");
//		
//		lineTax.setPercentage(20.0);
//		
//		lineTaxes.add(lineTax);
//		
//		record1.addKeyValue("$line_tax", lineTaxes);

/** End Inventory **/

/** Following methods are being used only by Activity modules */

//Tasks
//		record1.addFieldValue(Field.Tasks.DESCRIPTION, "Test Task");
//		
//		record1.addKeyValue("Currency",new Choice("INR"));
//		
//		RemindAt remindAt = new RemindAt();
//		
//		remindAt.setAlarm("FREQ=NONE;ACTION=EMAILANDPOPUP;TRIGGER=DATE-TIME:2020-07-03T12:30:00+05:30");
//		
//		record1.addFieldValue(Field.Tasks.REMIND_AT, remindAt);
//		
//		com.zoho.crm.api.record.Record whoId = new com.zoho.crm.api.record.Record();
//		
//		whoId.setId(3477061000004977055L);
//		
//		record1.addFieldValue(Field.Tasks.WHO_ID, whoId);
//		
//		record1.addFieldValue(Field.Tasks.STATUS,new Choice("Waiting for input"));
//		
//		record1.addFieldValue(Field.Tasks.DUE_DATE, LocalDate.of(2021, 1, 13));
//		
//		record1.addFieldValue(Field.Tasks.PRIORITY,new Choice("High"));
//		
//		record1.addKeyValue("$se_module", "Accounts");
//		
//		com.zoho.crm.api.record.Record whatId = new com.zoho.crm.api.record.Record();
//		
//		whatId.setId(3477061000000207118L);
//		
//		record1.addFieldValue(Field.Tasks.WHAT_ID, whatId);

/** Recurring Activity can be provided in any activity module*/

//		RecurringActivity recurringActivity = new RecurringActivity();
//		
//		recurringActivity.setRrule("FREQ=DAILY;INTERVAL=10;UNTIL=2020-08-14;DTSTART=2020-07-03");
//		
//		record1.addFieldValue(Field.Events.RECURRINGACTIVITY, recurringActivity);
//		
//Events
//		record1.addFieldValue(Field.Events.DESCRIPTION, "Test Events");
//		
//		OffsetDateTime startDateTime = OffsetDateTime.of(2020, 01, 02, 10, 00, 00, 00, ZoneOffset.of("+05:30")); 
//		
//		record1.addFieldValue(Field.Events.START_DATETIME, startDateTime);
//		
//		List<Participants> participants = new ArrayList<Participants>();
//		
//		Participants participant1 = new Participants();
//		
//		participant1.setParticipant("abc@gmail.com");
//		
//		participant1.setType("email");
//		
//		participant1.setId(3477061000005902017L);
//		
//		participants.add(participant1);
//		
//		Participants participant2 = new Participants();
//		
//		participant2.addKeyValue("participant", "3477061000005908033");
//		
//		participant2.addKeyValue("type", "lead");
//		
//		participants.add(participant2);
//		
//		record1.addFieldValue(Field.Events.PARTICIPANTS, participants);
//		
//		record1.addKeyValue("$send_notification", true);
//		
//		record1.addFieldValue(Field.Events.EVENT_TITLE, "New Automated Event");
//		
//		OffsetDateTime enddatetime = OffsetDateTime.of(2020, 05, 02, 10, 00, 00, 00, ZoneOffset.of("+05:30")); 
//		
//		record1.addFieldValue(Field.Events.END_DATETIME, enddatetime);
//		
//		OffsetDateTime remindAt = OffsetDateTime.of(2020, 05, 02, 05, 00, 00, 00, ZoneOffset.of("+05:30"));
//		
//		record1.addFieldValue(Field.Events.REMIND_AT, remindAt);
//		
//		record1.addFieldValue(Field.Events.CHECK_IN_STATUS, "PLANNED");
//		
//		record1.addKeyValue("$se_module", "Leads");
//		
//		com.zoho.crm.api.record.Record whatId = new com.zoho.crm.api.record.Record();
//		
//		whatId.setId(3477061000004381002);
//		
//		record1.addFieldValue(Field.Events.WHAT_ID, whatId);

/** End Activity **/

/** Following methods are being used only by Price_Books modules */
//		
//		List<PricingDetails> pricingDetails = new ArrayList<PricingDetails>();
//		
//		PricingDetails pricingDetail1 = new PricingDetails();
//		
//		pricingDetail1.setFromRange(1.0);
//		
//		pricingDetail1.setToRange(5.0);
//		
//		pricingDetail1.setDiscount(2.0);
//		
//		pricingDetails.add(pricingDetail1);
//		
//		PricingDetails pricingDetail2 = new PricingDetails();
//		
//		pricingDetail2.addKeyValue("from_range", 6.0);
//		
//		pricingDetail2.addKeyValue("to_range", 11.0);
//		
//		pricingDetail2.addKeyValue("discount", 3.0);
//		
//		pricingDetails.add(pricingDetail2);
//		
//		record1.addFieldValue(Field.Price_Books.PRICING_DETAILS, pricingDetails);
//		
//		record1.addKeyValue("Email", "raja.k12@zoho.com");
//		
//		record1.addFieldValue(Field.Price_Books.DESCRIPTION, "TEST");
//		
//		record1.addFieldValue(Field.Price_Books.PRICE_BOOK_NAME, "book_name");
//		
//		record1.addFieldValue(Field.Price_Books.PRICING_MODEL, new Choice("Flat"));

List < Tag > tagList = new ArrayList < Tag > ();

Tag tag = new Tag();

tag.setName("Testtask");

tagList.add(tag);

record1.setTag(tagList);

//Add Record instance to the list
records.add(record1);

//Set the list to Records in BodyWrapper instance
bodyWrapper.setData(records);

List < String > trigger = new ArrayList < String > ();

trigger.add("approval");

trigger.add("workflow");

trigger.add("blueprint");

bodyWrapper.setTrigger(trigger);

//bodyWrapper.setLarId("3477061000000087515");

HeaderMap headerInstance = new HeaderMap();

//Call createRecords method that takes moduleAPIName and BodyWrapper instance as parameter.
APIResponse < ActionHandler > response = recordOperations.createRecords(moduleAPIName, bodyWrapper, headerInstance);
3.0.0
Copied//Get instance of RecordOperations Class that takes moduleAPIName as parameter
$recordOperations = new RecordOperations();		
//Get instance of BodyWrapper Class that will contain the request body
$bodyWrapper = new BodyWrapper();
//List of Record instances
$records = array();
$recordClass = 'com\zoho\crm\api\record\Record';
//Get instance of Record Class
$record1 = new $recordClass();
/*
 * Call addFieldValue method that takes two arguments
 * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
 * 2 -> Value
 */
$field = new Field("");
$record1->addFieldValue(Leads::LastName(), "FROm PHP");
$record1->addFieldValue(Accounts::AccountName(), "Account_Name"); 
record1->addKeyValue("Date_1", new \DateTime('2021-03-08'));
$record1->addKeyValue("Date_Time_2", date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get())));
$startdatetime = date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
$record1->addFieldValue(Events::StartDateTime(), $startdatetime);
$record1->addFieldValue(Events::EventTitle(), "From PHP");
$enddatetime = date_create("2020-07-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));		
$record1->addFieldValue(Events::EndDateTime(), $enddatetime);
$tagList = array();
$tag = new Tag();
$tag->setName("Testtask");
array_push($tagList, $tag);
//Set the list to Tags in Record instance
$record1->setTag($tagList);
$bodyWrapper->setData($records);
$trigger = array("approval", "workflow", "blueprint");
$bodyWrapper->setTrigger($trigger);
$headerInstance = new HeaderMap();
$response = $recordOperations->createRecords($moduleAPIName,$bodyWrapper,$headerInstance);
3.0.0
Copied//Get instance of RecordOperations Class
RecordOperations recordOperations = new RecordOperations();
//Get instance of BodyWrapper Class that will contain the request body
BodyWrapper bodyWrapper = new BodyWrapper();
//List of Record instances
List<Com.Zoho.Crm.API.Record.Record> records = new List<Com.Zoho.Crm.API.Record.Record>();
//Get instance of Record Class
Com.Zoho.Crm.API.Record.Record record1 = new Com.Zoho.Crm.API.Record.Record();
/*
* Call addFieldValue method that takes two arguments
* 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
* 2 -> Value
*/
record1.AddFieldValue(Leads.CITY, "City");
record1.AddFieldValue(Leads.LAST_NAME, "Last Name");
record1.AddFieldValue(Leads.FIRST_NAME, "First Name");
record1.AddFieldValue(Leads.COMPANY, "KKRNP");
/*
* Call addKeyValue method that takes two arguments
* 1 -> A string that is the Field's API Name
* 2 -> Value
*/
record1.AddKeyValue("Custom_field", "Value");
record1.AddKeyValue("Custom_field_2", "value");
record1.AddKeyValue("Date_Time_2", new DateTimeOffset(new DateTime(2020, 05, 15, 12, 0, 0, DateTimeKind.Local)));
record1.AddKeyValue("Date_1", new DateTime(2021, 1, 13).Date);
record1.AddKeyValue("Subject", "AutomatedSDK");
List<FileDetails> fileDetails = new List<FileDetails>();
FileDetails fileDetail1 = new FileDetails();
fileDetail1.FileId = "ae9c7cefa418aec1d6a5cc2d9ab35c32537b7c2400dadca8ff55f620c65357da";
fileDetails.Add(fileDetail1);
FileDetails fileDetail2 = new FileDetails();
fileDetail2.FileId = "ae9c7cefa418aec1d6a5cc2d9ab35c32e0063e7321b5b4ca878a934519e6cdb2";
fileDetails.Add(fileDetail2);
FileDetails fileDetail3 = new FileDetails();
fileDetail3.FileId = "ae9c7cefa418aec1d6a5cc2d9ab35c323daf4780bfe0058133556f155795981f";
fileDetails.Add(fileDetail3);
record1.AddKeyValue("File_Upload", fileDetails);
//Products
record1.AddFieldValue(Products.PRODUCT_NAME, "Product_Name");
Com.Zoho.Crm.API.Record.Record vendorName = new Com.Zoho.Crm.API.Record.Record();
vendorName.AddFieldValue(Products.ID, 3477061000004996051);
record1.AddFieldValue(Products.VENDOR_NAME, vendorName);
record1.AddFieldValue(Products.PRODUCT_CATEGORY, new Choice<string>("Software"));
record1.AddFieldValue(Products.PRODUCT_ACTIVE, true);
record1.AddFieldValue(Products.SALES_START_DATE, new DateTime(2020, 10, 12));
record1.AddFieldValue(Products.SALES_END_DATE, new DateTime(2020, 12, 12));
record1.AddFieldValue(Products.TAXABLE, true);
List<Choice<string>> taxes = new List<Choice<string>>();
taxes.Add(new Choice<string>("MyTax22"));
taxes.Add(new Choice<string>("Sales Tax"));
taxes.Add(new Choice<string>("MyTax11"));
taxes.Add(new Choice<string>("Vat"));
taxes.Add(new Choice<string>("MyTax23"));
record1.AddFieldValue(Products.TAX, taxes);
/** Following methods are being used only by Inventory modules */
Com.Zoho.Crm.API.Record.Record dealName = new Com.Zoho.Crm.API.Record.Record();
dealName.AddFieldValue(Deals.ID, 3477061000004995070);
record1.AddFieldValue(Sales_Orders.DEAL_NAME, dealName);
Com.Zoho.Crm.API.Record.Record contactName = new Com.Zoho.Crm.API.Record.Record();
contactName.AddFieldValue(Contacts.ID, 3477061000004977055);
record1.AddFieldValue(Purchase_Orders.CONTACT_NAME, contactName);
Com.Zoho.Crm.API.Record.Record accountName = new Com.Zoho.Crm.API.Record.Record();
accountName.AddKeyValue("name", "automatedAccount");
record1.AddFieldValue(Quotes.ACCOUNT_NAME, accountName);
List<InventoryLineItems> inventoryLineItemList = new List<InventoryLineItems>();
InventoryLineItems inventoryLineItem = new InventoryLineItems();
LineItemProduct lineItemProduct = new LineItemProduct();
lineItemProduct.Id = 3477061000006611017;
inventoryLineItem.Product = lineItemProduct;
inventoryLineItem.Quantity = 1.5;
inventoryLineItem.ProductDescription = "productDescription";
inventoryLineItem.ListPrice = 10.0;
inventoryLineItem.Discount = "5.0";
inventoryLineItem.Discount = "5.25%";
List<LineTax> productLineTaxes = new List<LineTax>();
LineTax productLineTax = new LineTax();
productLineTax.Name = "MyTax22";
productLineTax.Percentage = 20.0;
productLineTaxes.Add(productLineTax);
inventoryLineItem.LineTax = productLineTaxes;
inventoryLineItemList.Add(inventoryLineItem);
record1.AddKeyValue("Product_Details", inventoryLineItemList);
List<LineTax> lineTaxes = new List<LineTax>();
LineTax lineTax = new LineTax();
lineTax.Name = "MyTax22";
lineTax.Percentage = 20.0;
lineTaxes.Add(lineTax);
record1.AddKeyValue("$line_tax", lineTaxes);
/** End Inventory **/
/** Following methods are being used only by Activity modules */
//Tasks
record1.AddFieldValue(Tasks.DESCRIPTION, "Test Task");
record1.AddKeyValue("Currency", new Choice<string>("INR"));
RemindAt remindAt = new RemindAt();
remindAt.Alarm = "FREQ=NONE;ACTION=EMAILANDPOPUP;TRIGGER=DATE-TIME:2020-09-03T12:30:00+05:30";
record1.AddFieldValue(Tasks.REMIND_AT, remindAt);
Com.Zoho.Crm.API.Record.Record whoId = new Com.Zoho.Crm.API.Record.Record();
whoId.Id = 3477061000004977055;
record1.AddFieldValue(Tasks.WHO_ID, whoId);
record1.AddFieldValue(Tasks.STATUS, new Choice<string>("Waiting for input"));
record1.AddFieldValue(Tasks.DUE_DATE, new DateTime(2021, 1, 13));
record1.AddFieldValue(Tasks.PRIORITY, new Choice<string>("High"));
record1.AddKeyValue("$se_module", "Accounts");
record1.AddFieldValue(Tasks.SUBJECT, "Email1");
Com.Zoho.Crm.API.Record.Record whatId = new Com.Zoho.Crm.API.Record.Record();
whatId.Id = 3477061000000207118;
record1.AddFieldValue(Tasks.WHAT_ID, whatId);
/** Recurring Activity can be provided in any activity module*/
RecurringActivity recurringActivity = new RecurringActivity();
recurringActivity.Rrule = "FREQ=DAILY;INTERVAL=10;UNTIL=2020-08-14;DTSTART=2020-07-03";
record1.AddFieldValue(Events.RECURRING_ACTIVITY, recurringActivity);
//Events
record1.AddFieldValue(Events.DESCRIPTION, "Test Events");
DateTimeOffset startDateTime = new DateTimeOffset(new DateTime(2020, 05, 15, 12, 0, 0, DateTimeKind.Local));
record1.AddFieldValue(Events.START_DATETIME, startDateTime);
List<Participants> participants = new List<Participants>();
Participants participant1 = new Participants();
participant1.Participant = "raja@gmail.com";
participant1.Type = "email";
participant1.Id = 3477061000005902017;
participants.Add(participant1);
Participants participant2 = new Participants();
participant2.AddKeyValue("participant", "3477061000007078158");
participant2.AddKeyValue("type", "lead");
participants.Add(participant2);
record1.AddFieldValue(Events.PARTICIPANTS, participants);
record1.AddKeyValue("$send_notification", true);
record1.AddFieldValue(Events.EVENT_TITLE, "New Automated Event");
DateTimeOffset enddatetime = new DateTimeOffset(new DateTime(2020, 09, 15, 12, 0, 0, DateTimeKind.Local));
record1.AddFieldValue(Events.END_DATETIME, enddatetime);
DateTimeOffset remindAt1 = new DateTimeOffset(new DateTime(2020, 08, 15, 12, 0, 0, DateTimeKind.Local));
record1.AddFieldValue(Events.REMIND_AT, remindAt1);
record1.AddFieldValue(Events.CHECK_IN_STATUS, "PLANNED");
record1.AddKeyValue("$se_module", "Leads");
Com.Zoho.Crm.API.Record.Record whatId1 = new Com.Zoho.Crm.API.Record.Record();
whatId1.Id = 3477061000004381002;
record1.AddFieldValue(Events.WHAT_ID, whatId1);
/** End Activity **/
/** Following methods are being used only by Price_Books modules */
List<PricingDetails> pricingDetails = new List<PricingDetails>();
PricingDetails pricingDetail1 = new PricingDetails();
pricingDetail1.FromRange = 1.0;
pricingDetail1.ToRange = 5.0;
pricingDetail1.Discount = 2.0;
pricingDetails.Add(pricingDetail1);
PricingDetails pricingDetail2 = new PricingDetails();
pricingDetail2.AddKeyValue("from_range", 6.0);
pricingDetail2.AddKeyValue("to_range", 11.0);
pricingDetail2.AddKeyValue("discount", 3.0);
pricingDetails.Add(pricingDetail2);
record1.AddFieldValue(Price_Books.PRICING_DETAILS, pricingDetails);
record1.AddKeyValue("Email", "raja.k126@zoho.com");
record1.AddFieldValue(Price_Books.DESCRIPTION, "TEST");
record1.AddFieldValue(Price_Books.PRICE_BOOK_NAME, "book_name");
record1.AddFieldValue(Price_Books.PRICING_MODEL, new Choice<string>("Flat1"));
List<Tag> tagList = new List<Tag>();
Tag tag = new Tag();
tag.Name = "Testtask";
tagList.Add(tag);
record1.Tag = tagList;
//Add Record instance to the list
records.Add(record1);
//Set the list to Records in BodyWrapper instance
bodyWrapper.Data = records;
List<string> trigger = new List<string>();
trigger.Add("approval");
trigger.Add("workflow");
trigger.Add("blueprint");
bodyWrapper.Trigger = trigger;
//bodyWrapper.LarId = "3477061000000087515";
HeaderMap headerInstance = new HeaderMap();
//Call CreateRecords method that takes moduleAPIName and BodyWrapper instance as parameter.
APIResponse<ActionHandler> response = recordOperations.CreateRecords(moduleAPIName, bodyWrapper,headerInstance);
3.0.0
Copied# Get instance of RecordOperations Class
record_operations = RecordOperations()
# Get instance of BodyWrapper Class that will contain the request body
request = BodyWrapper()
# List to hold Record instances
records_list = []
# Get instance of Record Class
record = Record()
# Value to Record's fields can be provided in any of the following ways
"""
Call add_field_value method that takes two arguments
Import the zcrmsdk.src.com.zoho.crm.api.record.field file
1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
2 -> Value
"""
record.add_field_value(Field.Leads.last_name(), 'Python SDK')
record.add_field_value(Field.Leads.first_name(), 'New')
record.add_field_value(Field.Leads.company(), 'Zoho')
record.add_field_value(Field.Leads.city(), 'City')
"""
Call add_key_value method that takes two arguments
1 -> A string that is the Field's API Name
2 -> Value
"""
record.add_key_value('Custom_field', 'Value')
record.add_key_value('Custom_field_2', 12)
record.add_key_value('Date', date(2020, 4, 9))
record.add_key_value('Discounted', 23.34)
file_details = []
file_detail = FileDetails()
file_detail.set_file_id('479f0f5eebf0fb982f99e3832b35d23e29f67c2868ee4c789f22579895383c8')
file_details.append(file_detail)
record.add_key_value('File_Upload_1', file_details)
"""
Following methods are being used only by Inventory modules
"""
deal_name = Record()
deal_name.add_field_value(Field.Deals.id(), 3409643000002000001)
record.add_field_value(Field.Sales_Orders.deal_name(), deal_name)
contact_name = Record()
contact_name.add_field_value(Field.Contacts.id(), 3409643000001074007)
record.add_field_value(Field.Sales_Orders.contact_name(), contact_name)
account_name = Record()
account_name.add_field_value(Field.Accounts.id(), 3409643000000692007)
record.add_field_value(Field.Sales_Orders.account_name(), account_name)
record.add_key_value("Discount", 10.5)
inventory_line_item_list = []
inventory_line_item = InventoryLineItems()
line_item_product = LineItemProduct()
line_item_product.set_id(3409643000000986033)
inventory_line_item.set_product(line_item_product)
inventory_line_item.set_quantity(3)
inventory_line_item.set_product_description('productDescription')
inventory_line_item.set_list_price(10.0)
inventory_line_item.set_discount('5.90')
product_line_taxes = []
product_line_tax = LineTax()
product_line_tax.set_name('Tax1')
product_line_tax.set_percentage(12.0)
product_line_taxes.append(product_line_tax)
inventory_line_item.set_line_tax(product_line_taxes)
inventory_line_item_list.append(inventory_line_item)
record.add_key_value('Product_Details', inventory_line_item_list)
line_taxes = []
line_tax = LineTax()
line_tax.set_name('Total-Tax')
line_tax.set_percentage(5.0)
line_taxes.append(line_tax)
record.add_key_value("$line_tax", line_taxes)
"""
End Inventory
"""
"""
Following methods are being used only by Activity modules
"""
record.add_field_value(Field.Tasks.description(), "New Task")
record.add_key_value('Currency', Choice('INR'))
remind_at = RemindAt()
remind_at.set_alarm("FREQ=NONE;ACTION=EMAILANDPOPUP;TRIGGER=DATE-TIME:2020-07-03T12:30:00+05:30")
record.add_field_value(Field.Tasks.remind_at(), remind_at)
who_id = Record()
who_id.set_id(3409643000000836001)
record.add_field_value(Field.Tasks.who_id(), who_id)
record.add_field_value(Field.Tasks.status(), Choice('Waiting for Input'))
record.add_field_value(Field.Tasks.due_date(), date(2020, 10, 10))
record.add_field_value(Field.Tasks.priority(), Choice('High'))
what_id = Record()
what_id.set_id(3409643000000692007)
record.add_field_value(Field.Tasks.what_id(), what_id)
record.add_key_value("$se_module", "Accounts")
# Recurring Activity can be provided in any activity module
recurring_activity = RecurringActivity()
recurring_activity.set_rrule('FREQ=DAILY;INTERVAL=10;UNTIL=2020-08-14;DTSTART=2020-07-03')
record.add_field_value(Field.Events.recurring_activity(), recurring_activity)
record.add_field_value(Field.Events.description(), "My Event")
start_date_time = datetime.fromisoformat('2020-07-03T12:30:00+05:30')
record.add_field_value(Field.Events.start_datetime(), start_date_time)
participants_list = []
participant = Participants()
participant.set_participant('test@gmail.com')
participant.set_type('email')
participants_list.append(participant)
participant = Participants()
participant.set_participant('3409643000000836001')
participant.set_type('contact')
participants_list.append(participant)
record.add_field_value(Field.Events.participants(), participants_list)
record.add_key_value("$send_notification", True)
record.add_field_value(Field.Events.event_title(), "New Automated Event")
end_date_time = datetime(2020, 9, 3, 10, 10, 10)
record.add_field_value(Field.Events.end_datetime(), end_date_time)
remind_at_value = datetime(2020, 7, 3, 8, 10, 10)
record.add_field_value(Field.Events.remind_at(), remind_at_value)
record.add_field_value(Field.Events.check_in_status(), 'PLANNED')
what_id = Record()
what_id.set_id(3409643000002157023)
record.add_field_value(Field.Events.what_id(), what_id)
record.add_key_value("$se_module", "Leads")
"""
End Activity
"""

"""
Following methods are being used only by Price_Books module
"""
pricing_details_list = []
pricing_detail = PricingDetails()
pricing_detail.set_from_range(1.0)
pricing_detail.set_to_range(5.0)
pricing_detail.set_discount(2.0)
pricing_details_list.append(pricing_detail)
pricing_detail = PricingDetails()
pricing_detail.add_key_value('from_range', 6.0)
pricing_detail.add_key_value('to_range', 11.0)
pricing_detail.add_key_value('discount', 3.0)
pricing_details_list.append(pricing_detail)
record.add_field_value(Field.Price_Books.pricing_details(), pricing_details_list)
record.add_key_value("Email", "z1@zoho.com")
record.add_field_value(Field.Price_Books.description(), "My Price Book")
record.add_field_value(Field.Price_Books.price_book_name(), 'book_name')
record.add_field_value(Field.Price_Books.pricing_model(), Choice('Flat'))
"""
End of Price_Books
"""
# Used when GDPR is enabled
data_consent = Consent()
data_consent.set_consent_remarks("Approved.")
data_consent.set_consent_through('Email')
data_consent.set_contact_through_email(True)
data_consent.set_contact_through_social(False)
record.add_field_value('Data_Processing_Basis_Details', data_consent)
tags_list = []
tag = Tag()
tag.set_name("My Record")
tags_list.append(tag)
# Add Record instance to the list
records_list.append(record)
# Set the list to data in BodyWrapper instance
request.set_data(records_list)
trigger = ["approval", "workflow", "blueprint"]
# Set the list containing the trigger operations to be run
request.set_trigger(trigger)
lar_id = '3409643000002157065'
# Set the larId
request.set_lar_id(lar_id)
process = ["review_process"]
# Set the array containing the process to be run
request.set_process(process)
# Get instance of HeaderMap Class
header_instance = HeaderMap()
# Call create_records method that takes BodyWrapper instance and module_api_name as parameters
response = record_operations.create_records(module_api_name, request,header_instance)
1.0.0
Copied//Get instance of RecordOperations Class
let recordOperations = new RecordOperations();
//Get instance of BodyWrapper Class that will contain the request body
let request = new BodyWrapper();
//Array to hold Record instances
let recordsArray = [];
//Get instance of Record Class
let record = new Record();
/* Value to Record's fields can be provided in any of the following ways */
/*
 * Call addFieldValue method that takes two arguments
 * Import the "zcrmsdk/core/com/zoho/crm/api/record/field" file
 * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
 * 2 -> Value
 */
record.addFieldValue(Field.Leads.LAST_NAME, "Node JS SDK");
record.addFieldValue(Field.Leads.FIRST_NAME, "Node");
record.addFieldValue(Field.Leads.COMPANY, "ZCRM");
record.addFieldValue(Field.Leads.CITY, "City");
/*
 * Call addKeyValue method that takes two arguments
 * 1 -> A string that is the Field's API Name
 * 2 -> Value
 */
record.addKeyValue("Custom_field", "Value");
record.addKeyValue("Custom_field_2", "value");
record.addKeyValue("Date_1", new Date(2020,10,20));
record.addKeyValue("Subject", "AutomatedSDK");
let fileDetails = [];
let fileDetail = new FileDetails();
fileDetail.setFileId("479f0f5eebf0fb982f99e3832b35d23e29f67c2868ee4c789f22579895383c8");
fileDetails.push(fileDetail);
fileDetail = new FileDetails();
fileDetail.setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c32e0063e7321b5b4ca878a934519e6cdb2");
fileDetails.push(fileDetail);
fileDetail = new FileDetails();
fileDetail.setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c323daf4780bfe0058133556f155795981f");
fileDetails.push(fileDetail);
record.addKeyValue("File_Upload_1", fileDetails);
//Used when GDPR is enabled
let dataConsent = new Consent();
dataConsent.setConsentRemarks("Approved.");
dataConsent.setConsentThrough("Email");
dataConsent.setContactThroughEmail(true);
dataConsent.setContactThroughSocial(false);
record.addKeyValue("Data_Processing_Basis_Details", dataConsent);
/** Following methods are being used only by Inventory modules */
let dealName = new Record();
dealName.addFieldValue(Field.Deals.ID, "3409643000002000001");
record.addFieldValue(Field.Sales_Orders.DEAL_NAME, dealName);
let contactName = new Record();
contactName.addFieldValue(Field.Contacts.ID, "3409643000001074007");
contactName.addFieldValue(Field.Sales_Orders.CONTACT_NAME, contactName);
let accountName = new Record();
accountName.addFieldValue(Field.Accounts.ID, "3409643000000692007");
record.addFieldValue(Field.Sales_Orders.ACCOUNT_NAME, accountName);
record.addKeyValue("Discount", 10.5);
let inventoryLineItemArray = [];
let inventoryLineItem = new InventoryLineItems();
let lineItemProduct = new LineItemProduct();
lineItemProduct.setId(3409643000000986033n);
inventoryLineItem.setProduct(lineItemProduct);
inventoryLineItem.setQuantity(3);
inventoryLineItem.setProductDescription("productDescription");
inventoryLineItem.setListPrice(10.0);
inventoryLineItem.setDiscount("5.90");
let productLineTaxes = [];
let productLineTax = new LineTax();
productLineTax.setName("Tax1");
productLineTax.setPercentage(20.0);
productLineTaxes.push(productLineTax);
inventoryLineItem.setLineTax(productLineTaxes);
inventoryLineItemArray.push(inventoryLineItem);
record.addKeyValue("Product_Details", inventoryLineItemArray);
let lineTaxes = [];
let lineTax = new LineTax();
lineTax.setName("Tax1");
lineTax.setPercentage(20.0);
lineTaxes.push(lineTax);
record.addKeyValue("$line_tax", lineTaxes);
/** End Inventory **/
/** Following methods are being used only by Activity modules */
record.addFieldValue(Field.Tasks.DESCRIPTION, "New Task");
record.addKeyValue("Currency", new Choice("INR"));
let remindAt = new RemindAt();
remindAt.setAlarm("FREQ=NONE;ACTION=EMAILANDPOPUP;TRIGGER=DATE-TIME:2020-07-03T12:30:00+05:30");
record.addFieldValue(Field.Tasks.REMIND_AT, remindAt);
let whoId = new Record();
whoId.setId(3409643000000836001n);
record.addFieldValue(Field.Tasks.WHO_ID, whoId);
record.addFieldValue(Field.Tasks.STATUS, new Choice("Waiting for Input"));
record.addFieldValue(Field.Tasks.DUE_DATE, new Date(2020,10,10));
record.addFieldValue(Field.Tasks.PRIORITY, new Choice("High"));
let whatId = new Record();
whatId.setId(3409643000000692007n);
record.addFieldValue(Field.Tasks.WHAT_ID, whatId);
record.addKeyValue("$se_module", "Accounts");
/** Recurring Activity can be provided in any activity module*/
let recurringActivity = new RecurringActivity();
recurringActivity.setRrule("FREQ=DAILY;INTERVAL=10;UNTIL=2020-08-14;DTSTART=2020-07-03");
record.addFieldValue(Field.Events.RECURRING_ACTIVITY, recurringActivity);
record.addFieldValue(Field.Events.DESCRIPTION, "My Event");
let startDateTime = new Date('October 15, 2020 05:35:32');
record.addFieldValue(Field.Events.START_DATETIME, startDateTime);
let participantsArray = [];
let participant = new Participant();
participant.setParticipant("test@gmail.com");
participant.setType("email");
participantsArray.push(participant);
participant = new Participant();
participant.setParticipant("3409643000000836001");
participant.setType("Contact");
participantsArray.push(participant);
record.addFieldValue(Field.Events.PARTICIPANTS, participantsArray);
record.addKeyValue("$send_notification", true);
record.addFieldValue(Field.Events.EVENT_TITLE, "New Automated Event");
let endDateTime = new Date('November 15, 2020 05:35:32');
record.addFieldValue(Field.Events.END_DATETIME, endDateTime);
let remindAt1 = new Date('October 15, 2020 04:35:32');
record.addFieldValue(Field.Events.REMIND_AT, remindAt1);
record.addFieldValue(Field.Events.CHECK_IN_STATUS, "PLANNED");
whatId = new Record();
whatId.setId(3409643000002157023n);
record.addFieldValue(Field.Tasks.WHAT_ID, whatId);
record.addKeyValue("$se_module", "Leads");
/** End Activity **/
/** Following methods are being used only by Price_Books module */
let pricingDetailsArray = [];
let pricingDetail = new PricingDetails();
pricingDetail.setFromRange(1.0);
pricingDetail.setToRange(5.0);
pricingDetail.setDiscount(2.0);
pricingDetailsArray.push(pricingDetail);
pricingDetail = new PricingDetails();
pricingDetail.addKeyValue("from_range", 6.0);
pricingDetail.addKeyValue("to_range", 11.0);
pricingDetail.addKeyValue("discount", 3.0);
pricingDetailsArray.push(pricingDetail);
record.addFieldValue(Field.Price_Books.PRICING_DETAILS, pricingDetailsArray);
record.addKeyValue("Email", "z1@zoho.com");
record.addFieldValue(Field.Price_Books.DESCRIPTION, "TEST");
record.addFieldValue(Field.Price_Books.PRICE_BOOK_NAME, "book_name");
record.addFieldValue(Field.Price_Books.PRICING_MODEL, new Choice("Flat"));
/** End of Price_Books */
let tagsArray = [];
let tag = new Tag();
tag.setName("Testtask");
tagsArray.push(tag);
//Add Record instance to the array
recordsArray.push(record);
//Set the array to data in BodyWrapper instance
request.setData(recordsArray);
let trigger = [];
trigger.push("approval");
trigger.push("workflow");
trigger.push("blueprint");
//Set the array containing the trigger operations to be run
request.setTrigger(trigger);
let larId = "3409643000002157065";
//Set the larId
request.setLarId(larId);
let process = ["review_process"];
//Set the array containing the process to be run
request.setProcess(process);
//Get instance of HeaderMap Class
let headerInstance = new HeaderMap();
//Call createRecords method that takes BodyWrapper instance and moduleAPIName as parameters
let response = await recordOperations.createRecords(moduleAPIName, request,headerInstance);
2.0.0
Copied# List to hold Record instances
records = []
# Get instance of Record Class
record = Record::Record.new
# """
# Call add_field_value method that takes two arguments
# 1 -> Call Field "::" and choose the module from the displayed list and press "." and choose the field name from the displayed list.
# 2 -> Value
# """
if module_api_name.downcase == 'Leads'.downcase
  record.add_field_value(Record::Field::Leads.Last_name, 'asdad')
  record.add_field_value(Record::Field::Leads.City, 'City')
  record.add_field_value(Record::Field::Leads.First_name, 'First Name')
  record.add_field_value(Record::Field::Leads.Company, 'KKRNP')
end

# file = Record::FileDetails.new
# file.file_id = "f46166fa14ce16c6e2622b3ce82830759c6334275dc8a317539bbda39a6ca056"
# files = [file]

# """
# Call add_key_value method that takes two arguments
# 1 -> A string that is the Field's API Name
# 2 -> Value
# """

if module_api_name == 'Contacts'
  file_details = []

  file_detail =  Record::FileDetails.new

  file_detail.file_id = '479f0f5eebf0fb982f99e3832b35d23e29f67c2868ee4c789f22579895383c8'

  file_details.push(file_detail)

  record.add_key_value('File_Upload_1', file_details)
end

# """
# Following methods are being used only by Inventory modules
# """
if %w[Quotes Sales_Orders Purchase_Orders Invoices].include? module_api_name
  line_item_product = Record::LineItemProduct.new
  line_item_product.id = 3_524_033_000_003_659_082
  inventory_line_item = Record::InventoryLineItems.new
  inventory_line_item.product = nil
  inventory_line_item.list_price = 10.0
  inventory_line_item.discount = '5.0'
  inventory_line_item.quantity = 123.2
  line_tax = Record::LineTax.new
  line_tax.name = 'Tax1'
  line_tax.percentage = 20.0
  line_taxes = [line_tax]
  inventory_line_item.line_tax = line_taxes
  inventory_line_items = [inventory_line_item]
  record.add_key_value('Product_Details', inventory_line_items)
  record.add_key_value('Subject', 'asd')
end
# """
# Following methods are being used only by Activity modules
# """
if %w[Tasks Events Calls].include? module_api_name
  remind_at = Record::RemindAt.new
  remind_at.alarm = 'FREQ=NONE;ACTION=EMAILANDPOPUP;TRIGGER=DATE-TIME:2020-07-03T12:30:00+05:30'
  who_id =  Record::Record.new
  who_id.id = 3_524_033_000_003_429_023
  record.add_field_value(Record::Field::Tasks.Who_id, who_id)
  participant_record = Record::Participants.new
  participant_record.participant = 'asdasd@gmail.com'
  participant_record.type = 'email'
  record.add_field_value(Record::Field::Events.Event_title, 'New Automated Event')
  endtime = DateTime.new(2019, 8, 10, 4, 11, 9, '+03:00')
  record.add_field_value(Record::Field::Events.End_datetime, endtime)
  starttime = DateTime.new(2019, 8, 10, 4, 10, 9, '+03:00')
  record.add_field_value(Record::Field::Events.Start_datetime, starttime)

  participants = [participant_record]
  record.add_field_value(Record::Field::Events.Start_datetime, starttime)

  recurring_activity = Record::RecurringActivity.new

  recurring_activity.rrule = 'FREQ=DAILY;INTERVAL=10;UNTIL=2020-08-14;DTSTART=2020-07-03'
  record.add_field_value(Record::Field::Events.Recurring_activity, recurring_activity)
end

if module_api_name == 'Price_Books'
  pricing_detail_record = Record::PricingDetails.new
  pricing_detail_record.from_range = 1.0
  pricing_detail_record.to_range = 1.0
  pricing_detail_record.discount = 1.0
  pricing_detail_records = [pricing_detail_record]
  record.add_key_value('Price_Book_Name', 'assd')
  record.add_field_value(Record::Field::Price_Books.Pricing_details, pricing_detail_records)
  record.add_field_value(Record::Field::Price_Books.Pricing_model, Util::Choice.new('Flat'))
end
# # Get instance of BodyWrapper Class that will contain the request body
records.push(record)
trigger = []
trigger.push('approval')

trigger.push('workflow')

trigger.push('blueprint')
# Get instance of BodyWrapper Class that will contain the request body
body_wrapper = Record::BodyWrapper.new
# Set the list to data in BodyWrapper instance
body_wrapper.data = records
# Set the lar_id in BodyWrapper instance
body_wrapper.lar_id = '213123131'
#set trigger
body_wrapper.trigger = trigger
process = ['review_process']
body_wrapper.process = process
# # Get instance of RecordOperations Class
rr = Record::RecordOperations.new
# Get instance of HeaderMap Class
hm = HeaderMap.new
# Call create_records method that takes BodyWrapper instance and module_api_name as parameters
response = rr.create_records(module_api_name,body_wrapper,hm)
1.0.0
Copied//Get instance of RecordOperations Class
let recordOperations = new ZCRM.Record.Operations();
//Get instance of BodyWrapper Class that will contain the request body
let request = new ZCRM.Record.Model.BodyWrapper();
//Array to hold Record instances
let recordsArray = [];
//Get instance of Record Class
let record = new ZCRM.Record.Model.Record();
/* Value to Record's fields can be provided in any of the following ways */
/*
 * Call addFieldValue method that takes two arguments
 * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
 * 2 -> Value
 */
record.addFieldValue(ZCRM.Record.Model.Field.Leads.LAST_NAME, "JS SDK");
record.addFieldValue(ZCRM.Record.Model.Field.Leads.FIRST_NAME, "JS");
record.addFieldValue(ZCRM.Record.Model.Field.Leads.COMPANY, "ZCRM");
record.addFieldValue(ZCRM.Record.Model.Field.Leads.CITY, "City");
/*
 * Call addKeyValue method that takes two arguments
 * 1 -> A string that is the Field's API Name
 * 2 -> Value
 */
record.addKeyValue("Custom_field", "Value");
record.addKeyValue("Custom_field_2", "value");
record.addKeyValue("Date_1", new Date(2020,10,20));
record.addKeyValue("Subject", "AutomatedSDK");
let fileDetails = [];
let fileDetail = new ZCRM.Record.Model.FileDetails();
fileDetail.setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c32e98a84dfc2df549e9a46a78e8a27d753");
fileDetails.push(fileDetail);
fileDetail = new ZCRM.Record.Model.FileDetails();
fileDetail.setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c32e0063e7321b5b4ca878a934519e6cdb2");
fileDetails.push(fileDetail);
fileDetail = new ZCRM.Record.Model.FileDetails();
fileDetail.setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c323daf4780bfe0058133556f155795981f");
fileDetails.push(fileDetail);
record.addKeyValue("File_Upload", fileDetails);
// Used when GDPR is enabled
let dataConsent = new ZCRM.Record.Model.Consent();
dataConsent.setConsentRemarks("Approved.");
dataConsent.setConsentThrough("Email");
dataConsent.setContactThroughEmail(true);
dataConsent.setContactThroughSocial(false);
record.addKeyValue("Data_Processing_Basis_Details", dataConsent);
/** Following methods are being used only by Inventory modules */
let dealName = new ZCRM.Record.Model.Record();
dealName.addFieldValue(ZCRM.Record.Model.Field.Deals.ID, 3477067850014n);
record.addFieldValue(ZCRM.Record.Model.Field.Sales_Orders.DEAL_NAME, dealName);
let contactName = new ZCRM.Record.Model.Record();
contactName.addFieldValue(ZCRM.Record.Model.Field.Contacts.ID, 34096431074007n);
contactName.addFieldValue(ZCRM.Record.Model.Field.Sales_Orders.CONTACT_NAME, contactName);
let accountName = new ZCRM.Record.Model.Record();
accountName.addFieldValue(ZCRM.Record.Model.Field.Accounts.ID, 34770617969021n);
record.addFieldValue(ZCRM.Record.Model.Field.Sales_Orders.ACCOUNT_NAME, accountName);
record.addKeyValue("Discount", 10.5);
let inventoryLineItemArray = [];
let inventoryLineItem = new ZCRM.Record.Model.InventoryLineItems();
let lineItemProduct = new ZCRM.Record.Model.LineItemProduct();
lineItemProduct.setId(34770617247012n);
inventoryLineItem.setProduct(lineItemProduct);
inventoryLineItem.setQuantity(3);
inventoryLineItem.setProductDescription("productDescription");
inventoryLineItem.setListPrice(10.0);
inventoryLineItem.setDiscount("5.90");
let productLineTaxes = [];
let productLineTax = new ZCRM.Record.Model.LineTax();
productLineTax.setName("MyTax11");
productLineTax.setPercentage(20.0);
productLineTaxes.push(productLineTax);
inventoryLineItem.setLineTax(productLineTaxes);
inventoryLineItemArray.push(inventoryLineItem);
record.addKeyValue("Product_Details", inventoryLineItemArray);
let lineTaxes = [];
let lineTax = new ZCRM.Record.Model.LineTax();
lineTax.setName("MyTax1122");
lineTax.setPercentage(20.0);
lineTaxes.push(lineTax);
record.addKeyValue("$line_tax", lineTaxes);
/** End Inventory **/
/** Following methods are being used only by Activity modules */
record.addFieldValue(ZCRM.Record.Model.Field.Tasks.DESCRIPTION, "New Task");
record.addKeyValue("Currency", new Choice("INR"));
let remindAt = new ZCRM.Record.Model.RemindAt();
remindAt.setAlarm("FREQ=NONE;ACTION=EMAILANDPOPUP;TRIGGER=DATE-TIME:2021-07-03T12:30:00+05:30");
record.addFieldValue(ZCRM.Record.Model.Field.Tasks.REMIND_AT, remindAt);
let whoId = new ZCRM.Record.Model.Record();
whoId.setId(34770617955002n);
record.addFieldValue(ZCRM.Record.Model.Field.Tasks.WHO_ID, whoId);
record.addFieldValue(ZCRM.Record.Model.Field.Tasks.STATUS, new Choice("Waiting for Input"));
record.addFieldValue(ZCRM.Record.Model.Field.Tasks.DUE_DATE, new Date(2020,10,10));
record.addFieldValue(ZCRM.Record.Model.Field.Tasks.PRIORITY, new Choice("High"));
let whatId = new ZCRM.Record.Model.Record();
whatId.setId(34770617969021n);
record.addFieldValue(ZCRM.Record.Model.Field.Tasks.WHAT_ID, whatId);
record.addKeyValue("$se_module", "Accounts");
/** Recurring Activity can be provided in any activity module*/
let recurringActivity = new ZCRM.Record.Model.RecurringActivity();
recurringActivity.setRrule("FREQ=DAILY;INTERVAL=10;UNTIL=2020-08-14;DTSTART=2020-07-03");
record.addFieldValue(ZCRM.Record.Model.Field.Events.RECURRING_ACTIVITY, recurringActivity);
record.addFieldValue(ZCRM.Record.Model.Field.Events.DESCRIPTION, "My Event");
let startDateTime = new Date('October 15, 2020 05:35:32');
record.addFieldValue(ZCRM.Record.Model.Field.Events.START_DATETIME, startDateTime);
let participantsArray = [];
let participant = new ZCRM.Record.Model.Participants();
participant.setParticipant("test@gmail.com");
participant.setType("email");
participantsArray.push(participant);
participant = new ZCRM.Record.Model.Participants();
participant.setParticipant("34770617634005");
participant.setType("contact");
participantsArray.push(participant);
record.addFieldValue(ZCRM.Record.Model.Field.Events.PARTICIPANTS, participantsArray);
record.addKeyValue("$send_notification", true);
record.addFieldValue(ZCRM.Record.Model.Field.Events.EVENT_TITLE, "New Automated Event");
let endDateTime = new Date('November 15, 2020 05:35:32');
record.addFieldValue(ZCRM.Record.Model.Field.Events.END_DATETIME, endDateTime);
let remindAt1 = new Date('October 15, 2020 04:35:32');
record.addFieldValue(ZCRM.Record.Model.Field.Events.REMIND_AT, remindAt1);
record.addFieldValue(ZCRM.Record.Model.Field.Events.CHECK_IN_STATUS, "PLANNED");
whatId = new ZCRM.Record.Model.Record();
whatId.setId(34770619074373n);
record.addFieldValue(ZCRM.Record.Model.Field.Tasks.WHAT_ID, whatId);
record.addKeyValue("$se_module", "Leads");
/** End Activity **/
/** Following methods are being used only by Price_Books module */
let pricingDetailsArray = [];
let pricingDetail = new ZCRM.Record.Model.PricingDetails();
pricingDetail.setFromRange(1.0);
pricingDetail.setToRange(5.0);
pricingDetail.setDiscount(2.0);
pricingDetailsArray.push(pricingDetail);
pricingDetail = new ZCRM.Record.Model.PricingDetails();
pricingDetail.addKeyValue("from_range", 6.0);
pricingDetail.addKeyValue("to_range", 11.0);
pricingDetail.addKeyValue("discount", 3.0);
pricingDetailsArray.push(pricingDetail);
record.addFieldValue(ZCRM.Record.Model.Field.Price_Books.PRICING_DETAILS, pricingDetailsArray);
record.addKeyValue("Email", "z2@zoho.com");
record.addFieldValue(ZCRM.Record.Model.Field.Price_Books.DESCRIPTION, "TEST");
record.addFieldValue(ZCRM.Record.Model.Field.Price_Books.PRICE_BOOK_NAME, "book_name");
record.addFieldValue(ZCRM.Record.Model.Field.Price_Books.PRICING_MODEL, new Choice("Flat"));
/** End of Price_Books */
let tagsArray = [];
let tag = new ZCRM.Tag.Model.Tag();
tag.setName("Testtask");
tagsArray.push(tag);
record.setTag(tagsArray);
//Add Record instance to the array
recordsArray.push(record);
//Set the array to data in BodyWrapper instance
request.setData(recordsArray);
let trigger = [];
trigger.push("approval");
trigger.push("workflow");
trigger.push("blueprint");
//Set the array containing the trigger operations to be run
request.setTrigger(trigger);
let larId = "34096432157065";
//Set the larId
request.setLarId(larId);
let process = ["review_process"];
//Set the array containing the process to be run
request.setProcess(process);
//Call createRecords method that takes BodyWrapper instance and moduleAPIName as parameters
let response = await recordOperations.createRecords(moduleAPIName, request);

Sample Input

Copied{
    "data": [
        {
            "Last_Name": "ext contact 1",
            "Account_Name": {
                "External_Account_ID": "externalaccount1"
            }
        }
    ]
}

Sample Response

Copied{
    "data": [
        {
            "code": "SUCCESS",
            "details": {
                "Modified_Time": "2020-10-22T01:35:09-11:00",
                "Modified_By": {
                    "name": "Patricia Boyle",
                    "id": "554023000000235011"
                },
                "Created_Time": "2020-10-22T01:35:09-11:00",
                "id": "554023000001627036",
                "Created_By": {
                    "name": "Patricia Boyle",
                    "id": "554023000000235011"
                }
            },
            "message": "record added",
            "status": "success"
        }
    ]
}
Creating an inventory module's record with external fields in the line items
  • In this example, we will create a quote by using the external values in the Product_Details section that comprises the associated product and the price book. So, Quotes is the base module's API name, the API names of the external fields in the Products and Price Books modules are External_Product_ID and External_Price_book_ID, respectively.

Sample Request

Copiedcurl "https://www.zohoapis.com/crm/v2/Quotes"
-X POST
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-H "X-EXTERNAL: Quotes.Product_Details.product.External_Product_ID, Quotes.Product_Details.book.External_Price_book_ID"
-d "@sample.json"

Sample Input

Copied{
    "data": [
        {
            "External_Quote_ID": "quote1",
            "Subject": "Quote 1",
            "Product_Details": [
                {
                    "product": {
                        "External_Product_ID": "12345678900"
                    },
                    "book": {
                        "External_Price_book_ID": "pricebook1"
                    },
                    "quantity": 100
                }
            ]
        }
    ]
}

Sample Response

Copied{
    "data": [
        {
            "code": "SUCCESS",
            "details": {
                "Modified_Time": "2019-12-12T23:35:47+05:30",
                "Modified_By": {
                    "name": "Patricia Boyle",
                    "id": "554023000000235011"
                },
                "Created_Time": "2019-12-12T23:35:47+05:30",
                "id": "111111000000133093",
                "Created_By": {
                    "name": "Patricia Boyle",
                    "id": "554023000000235011"
                }
            },
            "message": "record added",
            "status": "success"
        }
    ]
}
Inserting a subform lookup record through an external field in the associated module 
  • In this example, Subform_External is the API name of the subform in the Contacts module. It has a look up field to the Deals module. The Deals module has an external field External_Deal_ID. We will reference this external field in the subform and insert a record in the Contacts module.

Sample Request

Copiedcurl "https://www.zohoapis.com/crm/v2/Contacts"
-X POST
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-H "X-EXTERNAL: Contacts.Subform_External.Deal_Lookup.External_Deal_ID"
-d "@sample.json"

Sample Input

Copied{
    "data": [
        {
            "Last_Name": "Contact with a Subform",
            "Subform_External": [
                {
                    "Deal_Lookup": {
                        "External_Deal_ID": "userdeal1"
                    }
                }
            ]
        }
    ]
}

Sample Response

Copied{
    "data": [
        {
            "code": "SUCCESS",
            "details": {
                "Modified_Time": "2019-12-12T23:35:47+05:30",
                "Modified_By": {
                    "name": "Patricia Boyle",
                    "id": "554023000000235011"
                },
                "Created_Time": "2019-12-12T23:35:47+05:30",
                "id": "111111000000134014",
                "Created_By": {
                    "name": "Patricia Boyle",
                    "id": "554023000000235011"
                }
            },
            "message": "record added",
            "status": "success"
        }
    ]
}
Inserting an Event record and associating What_Id through an external field

In this example, External_Account_ID is the API name of the external field in the Accounts module. What_Id in the Events module takes the Account's name as its value. We will reference this external field in the Accounts module to the What_Id field and insert an event.

Note

  • The What_Id lookup can be mapped to different modules and so while pointing to an external field from What_Id lookup in the X-External header, you should use "->Module Name.External field name” and not “. External field name”.
  • Also, while pointing to any Multi module lookup in the X-External header , you should use “->Module Name.External field name”.

 

Sample Request

Copiedcurl "https://www.zohoapis.com/crm/v2/Events"
-X POST
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-H "X-EXTERNAL: Events.What_Id->Accounts.External_Account_ID"
-d "@sample.json"

Sample Input

Copied{
    "data": [
        {
            "se_module": "Accounts",
            "What_Id": {
                "External_Account_ID": "useraccount1"
            },
            "Event_Title": "Event Kaizen",
            "Start_DateTime": "2020-05-10T10:10:10+05:30",
            "End_DateTime": "2020-05-10T11:10:10+05:30"
        }
    ]
}

Sample Response

Copied{
    "data": [
        {
            "code": "SUCCESS",
            "details": {
                "Modified_Time": "2019-12-12T23:35:47+05:30",
                "Modified_By": {
                    "name": "Patricia Boyle",
                    "id": "554023000000235011"
                },
                "Created_Time": "2019-12-12T23:35:47+05:30",
                "id": "111111000000137001",
                "Created_By": {
                    "name": "Patricia Boyle",
                    "id": "554023000000235011"
                }
            },
            "message": "record added",
            "status": "success"
        }
    ]
}
Inserting an Event record and associating What_Id and Participant through external fields
  • In this example, External_Account_ID and External_Contact_ID are the API names of the external fields in the Accounts and Contacts modules, respectively. What_Id in the Events module takes the Account's name as its value. "participant" is a JSON object in the Participants array. We will reference these external values and insert an event.

Note

  • If you specify the value of the external field in the participant JSON object and the record ID of the external field in the Contacts module, the system considers only the value of the external field if you specify only the participant in the header.
  • The What_Id lookup can be mapped to different modules and so while pointing to an external field from What_Id lookup in the X-External header, you should use "->Module Name.External field name” and not “.External field name”.
  • Also, while pointing to any Multi module lookup in the X-External header, you should use “->Module Name.External field name”. 

Possible Errors

  • DUPLICATE_DATAHTTP 400

    The external field contains duplicate data.
    Resolution: Input unique data to the external field.

  • INVALID_DATAHTTP 400

    The external ID of the lookup field or the Price Book is incorrect
    Resolution: Specify the correct external ID. Refer to the "details" in the error response to know which external ID is incorrect.

Sample Request

Copiedcurl "https://www.zohoapis.com/crm/v2/Events"
-X POST
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-H "X-EXTERNAL: Events.What_Id->Accounts.External_Account_ID, Events.Participants.participant->Contacts.External_Contact_ID"
-d "@sample.json"

Sample Input

Copied{
    "data": [
        {
            "External_Event_ID": "Event Kaizen 1",
            "Last_Name": "Contact 1",
            "Participants": [
                {
                    "type": "contact",
                    "participant": {
                        "External_Contact_ID": "participant1"
                    }
                }
            ],
            "What_Id": {
                "External_Account_ID": "useraccount1"
            },
            "$se_module": "Accounts",
            "Event_Title": "Kaizen 1",
            "Start_DateTime": "2020-05-10T10:10:10+05:30",
            "End_DateTime": "2020-05-10T11:10:10+05:30"
        }
    ]
}

Sample Response

Copied{
    "data": [
        {
            "code": "SUCCESS",
            "details": {
                "Modified_Time": "2019-12-12T23:35:47+05:30",
                "Modified_By": {
                    "name": "Patricia Boyle",
                    "id": "554023000000235011"
                },
                "Created_Time": "2019-12-12T23:35:47+05:30",
                "id": "111111000000139016",
                "Created_By": {
                    "name": "Patricia Boyle",
                    "id": "554023000000235011"
                }
            },
            "message": "record added",
            "status": "success"
        }
    ]
}