Update Records

Purpose

To update existing entities in the module.

Request URL

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

module_api_name - The API name of the module

Modules supported in Get List of Records are supported here.

Request Method

PUT

Scope

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

Possible module namesPossible operation types
leads, accounts, contacts, deals, campaigns, tasks, cases, events, calls, solutions, products, vendors, pricebooks, quotes, salesorders, purchaseorders, invoices, custom, and notesALL - Full access to the record
WRITE - Edit records in the module
UPDATE - Update records in the module

Note: For custom modules, use the scope ZohoCRM.modules.custom.{operation_type}

Possible Errors

HTTP StatusError CodeMessageReason
400INVALID_MODULEThe module name given seems to be invalidInvalid module name or no tab permission, or the module could have been removed from the organized module
400INVALID_MODULEThe given module is not supported in APIThe modules such as Documents and Projects are not supported in the current API. (This error will not be shown, once these modules are supported.)

Note:

  • An error is thrown if the field value length is more than the maximum length defined for that field.

  • If an API is used inside a Function and the field value length exceeds the limit, then that function receives error response from the API. For ex: If the max length for a "Text field" is defined as 10, then value given for it in API cannot be "12345678901", as it has 11 characters.

  • Duplicates are checked for every insert record API call based on unique fields.

  • A maximum of 100 records can be inserted per API call.

  • You must use only Field API names in the input. You can obtain the field API names from

    • Fields metadata API (the value for the key “api_name” for every field). (Or)

    • Setup > Developer Space > APIs > API Names > {{Module}}. Choose “Fields” from the “Filter By” drop-down.

  • The trigger input can be workflow, approval, or blueprint. If the trigger is not mentioned, the workflows, approvals and blueprints related to the API will get executed. Enter the trigger value as [] to not execute the workflows.

  • Records with Subform details can also be updated to CRM using the Records API. Please look at Subforms API to learn more about updating subform information within a record.

  • $approved key is used to set the records to be created in approval mode. It is mostly used for leads and contacts procured from webforms.

  • If the update API calls for a record are from DRE(Functions), due to workflow triggered on the same record's create/update, workflow alone will not get executed, irrespective of the trigger param configuration.

  • Refer Response Structure for more details about the JSON keys, values, and their descriptions. You can also use the sample response of each module as the input when you insert, update, or upsert a record in that corresponding module.

Sample Attributes

The following table gives you specific details about each field type in Zoho CRM and their limitations.
The JSON type and the data type of the field-types are extracted from fields meta data API.
JSON type - Tells in what format the field should be passed in request-body or will be received in response.
Data type - Tells the type of data that can be stored in the corresponding field-type. It is mentioned below each Attribute.

 
AttributeJSON TypeLimitationsSample
Single Line
Text
StringAccepts up to 255 characters.
Accepts alphanumeric and special characters.
"Last_Name": "Mike O'Leary"
Multi Line
Textarea
StringSmall - accepts up to 2000 characters.
Large - accepts up to 32000 characters.
You will not be able to use this field to create custom views, reports or other filters.
Accepts alphanumeric and special characters.
"Multi_Line_1": "This is the first line \n Now for the second Line"
Email
Email
StringAccepts valid email IDs."Email_1": "p.boyle@zylker.com"
Phone
Phone
StringAccepts up to 30 characters. This limit may vary based on the value configured in 'Number of characters allowed' in the properties pop-up of the field, in UI.
Accepts only numeric characters and '+' (to add extensions).
The regex pattern in Zoho CRM to validate this field's value is "[0-9a-zA-Z!#;%\\*\\^\\(\\)=\\{\\}\\[\\]\\?`~_\\-\\.\\$@\\?\\,\\:\\'\\/\\!\\P{InBasicLatin}\\|\\\\\\s\\+]+"
"Phone_1": "9900000000"
Picklist
Picklist
StringYou can either pass an existing pick list value or add a new one.
The pick list value accepts all alphanumeric and special characters.
"Industry": "automobile"
Multi-Select Picklist
Multi-select Picklist
JSON arrayYou can either pass existing pick list values or add a new one.
The pick list value accepts all alphanumeric and special characters.
"Courses_Opted": [
"Analytics",
"Big data"
]
Date
Date in ISO 8601 format
StringAccepts date in yyyy-MM-dd format"Date_1": "2017-08-16"
Date/time
DateTime in ISO 8601 format
StringAccepts date and time in yyyy-MM-ddTHH:mm:ss±HH:mm ISO 8601 format"Date_Time": "2017-08-16T14:32:23+05:30"
Date_Time is in ISO8601 format and the time zone is the current user's time zone.
Number
Integer
IntegerAccepts numbers up to 9 digits. This limit may vary based on the value configured in 'Maximum digits allowed' in the properties pop-up of the field, in UI.
Accepts only numeric values.
"No_of_Employees": 350
Currency
Currency
DoubleBefore decimal point - accepts numbers up to 16 digits. This limit may vary based on the value configured in 'Maximum digits allowed' in the properties pop-up of the field, in UI.
After decimal point - accepts precision up to 9 digits. This limit may vary based on the value configured in 'Number of decimal places' in the properties pop-up of the field, in UI.
Accepts only numeric values.
"Annual_Revenue": 250000.90
Decimal
Double
DoubleBefore decimal point - accepts numbers up to 16 digits. This limit may vary based on the value configured in 'Maximum digits allowed' in the properties pop-up of the field, in UI.
After decimal point - accepts precision up to 9 digits. This limit may vary based on the value configured in 'Number of decimal places' in the properties pop-up of the field, in UI.
Accepts only numeric values.
"Decimal_1": 250000.50
Percent
Double
DoubleAccepts numbers up to 5 digits.
Accepts only numeric values.
"Percentage": 25
Long Integer
BigInt
StringAccepts numbers up to 18 digits. This limit may vary based on the value configured in 'Maximum digits allowed' in the properties pop-up of the field, in UI.
Accepts only numeric values.
"EAN_Code":"0012345600012"
Checkbox
Boolean
BooleanAccepts only Boolean values(true,false)."Email_Opt_Out": true
URL
Website
StringAccepts valid URLs.
The regex pattern in Zoho CRM to validate this field's value is "^(http:\\/\\/www.|https:\\/\\/www.|ftp:\\/\\/www.|www.|http:\\/\\/|https:\\/\\/|ftp:\\/\\/|){1}[^\\x00-\\x19\\x22-\\x27\\x2A-\\x2C\\x2E-\\x2F\\x3A-\\x40\\x5B-\\x5E\\x60\\x7B\\x7D-\\x7F]+(\\.[^\\x00-\\x19\\x22\\x24-\\x2C\\x2E-\\x2F\\x3C\\x3E\\x40\\x5B-\\x5E\\x60\\x7B\\x7D-\\x7F]+)+(\\/[^\\x00-\\x19\\x22\\x3C\\x3E\\x5E\\x7B\\x7D-\\x7D\\x7F]*)*$"
"URL": "https://www.zylker.com"
Lookup
Lookup
JSON objectAccepts unique ID of the record, which you can get through Get Records API."Lookup" : {
"id" : "425248000000104001"
}
User
User Lookup
JSON objectThis is a default look-up field to users in Zoho CRM."User":
{
"name":"Patricia Boyle",
"id":"4150868000000623001"
}

Sample Request

In the request, "@updatelead.json" contains the sample input.


				curl "https://www.zohoapis.com/crm/v2/Leads"
-X PUT
-d "@updatelead.json"
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"			

Sample Input


				{
  "data": [
    {
      "id": "554023000000527002",
      "Company": "Zylker",
      "State":"Baltimore"
    },
    {
      "id": "554023000000527003",
      "Company": "abc",
      "State":"Baltimore"
    }
  ],
  "trigger": [
    "approval"
  ]
}			

Sample Response


				{
  "data": [
    {
      "code": "SUCCESS",
      "details": {
        "Modified_Time": "2019-05-02T11:17:33+05:30",
        "Modified_By": {
          "name": "Patricia Boyle",
          "id": "554023000000235011"
        },
        "Created_Time": "2019-05-02T11:17:33+05:30",
        "id": "554023000000527002",
        "Created_By": {
          "name": "Patricia Boyle",
          "id": "554023000000235011"
        }
      },
      "message": "record updated",
      "status": "success"
    },
    {
      "code": "SUCCESS",
      "details": {
        "Modified_Time": "2019-05-02T11:17:33+05:30",
        "Modified_By": {
          "name": "Patricia Boyle",
          "id": "554023000000235011"
        },
        "Created_Time": "2019-05-02T11:17:33+05:30",
        "id": "554023000000527003",
        "Created_By": {
          "name": "Patricia Boyle",
          "id": "554023000000235011"
        }
      },
      "message": "record updated",
      "status": "success"
    }
  ]
}			

Sample Request


				$moduleIns=ZCRMRestClient::getInstance()->getModuleInstance("Invoices"); //to get the instance of the module
$records=array();

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

$record=ZCRMRecord::getInstance("Invoices","554023000000527034"); //to get the instance of the record
$record->setFieldValue("Subject","Invoice3");  //This function use to set FieldApiName and value similar to all other FieldApis and Custom field
$record->setFieldValue("Account_Name","554023000000366005");
$lineItem=ZCRMInventoryLineItem::getInstance("554023000000504001");  //To get ZCRMInventoryLineItem instance
$lineItem->setDescription("Product_description");  //To set line item description
$lineItem ->setDiscount(20);  //To set line item discount
$lineItem->setListPrice(3412);  //To set line item list price

$taxInstance1=ZCRMTax::getInstance("VAT"); //to get the tax instance
$taxInstance1->setPercentage(20); //to set the tax percentage
$taxInstance1->setValue(50); //to set the  tax value
$lineItem->addLineTax($taxInstance1); //to add the tax to the line item

$lineItem->setQuantity(101);  //To set product quantity to this line item
$record->addLineItem($lineItem); //to add the line item to the record of invoice

array_push($records, $record); //pushing the record to the array

//$record=ZCRMRecord::getInstance("{module_api_name}","{record_id}");
//$record->setFieldValue("Subject","test54");  //This function use to set FieldApiName and value similar to all other FieldApis and Custom field
//$record->setFieldValue("Account_Name","{account_id}");

//array_push($records, $record); //pushing the record to the array

$responseIn=$moduleIns->updateRecords($records); //updating the records

foreach($responseIn->getEntityResponses() as $responseIns){
    echo "HTTP Status Code:".$responseIn->getHttpStatusCode();  //To get http response code
    echo "Status:".$responseIns->getStatus();  //To get response status
    echo "Message:".$responseIns->getMessage();  //To get response message
    echo "Code:".$responseIns->getCode();  //To get status code
    echo "Details:".json_encode($responseIns->getDetails());
}			

Sample Response


				{
    "data": [
       {
            "message": "record updated",
            "details": {
                "created_by": {
                    "id": "4108880000086001",
                    "name": "Patricia Boyle"
                },
                "id": "554023000000527034",
                "modified_by": {
                    "id": "4108880000086001",
                    "name": "Patricia Boyle"
                },
                "modified_time": "2016-04-28T17:59:21+05:30",
                "created_time": "2016-04-28T17:59:21+05:30"
            },
            "status": "success",
            "code": "SUCCESS"
        }
    ]
}			

Sample Request


				def update_records(self):
    try:
        record_ins_list = list()
        record = zcrmsdk.ZCRMRecord.get_instance('Invoices')  # Module API Name
        record.set_field_value('id', 554023000000527034) # record id
        record.set_field_value('Subject', 'Invoice')  # This method use to set FieldApiName and value similar to all other FieldApis and Custom field
        record.set_field_value('Account_Name', 'Zylker')
        record.set_field_value('Price_Book_Name', 'Price_book_1')
        record.set_field_value('Pricing_Model', 'Flat')
        record.set_field_value('Event_Title', 'Title')
        record.set_field_value('Start_DateTime', '2018-09-04T15:52:21+05:30')
        record.set_field_value('End_DateTime', '2019-01-04T15:52:21+05:30')
        record.set_field_value('Product_Name', 'product_1')
        user = zcrmsdk.ZCRMUser.get_instance(347706100001, 'Patricia Boyle')  # user id and user name
        record.set_field_value('Owner', user)

        # Following methods are used only by Inventory modules
        taxIns = zcrmsdk.ZCRMTax.get_instance("Vat")

        record.tax_list.append(taxIns)

        pricing = zcrmsdk.ZCRMPriceBookPricing(None)
        pricing.to_range = 5
        pricing.from_range = 1
        pricing.discount = 0
        record.price_details.append(pricing)

        pricing = zcrmsdk.ZCRMPriceBookPricing(None)
        pricing.to_range = 11
        pricing.from_range = 6
        pricing.discount = 1
        record.price_details.append(pricing)

        pricing = zcrmsdk.ZCRMPriceBookPricing(None)
        pricing.to_range = 17
        pricing.from_range = 12
        pricing.discount = 2
        record.price_details.append(pricing)

        # participants = zcrmsdk.ZCRMEventParticipant(3477061000000,'contact')  # Contacts record id and participant type
        # record.participants.append(participants)

        # participants = zcrmsdk.ZCRMEventParticipant('usermail@domain.com', 'email')
        # participants.email = 'usermail@domain.com'
        # participants.name = 'username'
        # participants.is_invited = 'true'
        # record.participants.append(participants)

        line_item = zcrmsdk.ZCRMInventoryLineItem.get_instance(zcrmsdk.ZCRMRecord.get_instance('Products', 347706100001))  # module api name and record id
        line_item.discount = 10
        line_item.list_price = 8
        line_item.description = 'Product Description'
        line_item.quantity = 100
        line_item.tax_amount = 2.5
        taxIns = zcrmsdk.ZCRMTax.get_instance("Vat")
        taxIns.percentage = 5
        line_item.line_tax.append(taxIns)
        record.add_line_item(line_item)

        line_tax = []
        line_tax_row1 = {}
        line_tax_row1['percentage'] = 12.5
        line_tax_row1['name'] = 'Sales Tax'
        line_tax.append(line_tax_row1)
        line_tax_row2 = {}
        line_tax_row2['percentage'] = 8.5
        line_tax_row2['name'] = 'Common Tax'
        line_tax.append(line_tax_row2)

        record.set_field_value('$line_tax', line_tax)
        record_ins_list.append(record)

        resp = zcrmsdk.ZCRMModule.get_instance('Invoices').update_records(record_ins_list)
        print(resp.status_code)
        entity_responses = resp.bulk_entity_response
        for entity_response in entity_responses:
            print(entity_response.details)
            print(entity_response.status)
            print(entity_response.message)
            print(entity_response.data.entity_id)
            print(entity_response.data.created_by.id)
            print(entity_response.data.created_time)
            print(entity_response.data.modified_by.id)
            print("\n\n")
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code) 
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)			

Sample Response


				{
    "data": [
       {
            "message": "record updated",
            "details": {
                "created_by": {
                    "id": "4108880000086001",
                    "name": "Patricia Boyle"
                },
                "id": "4108880000478060",
                "modified_by": {
                    "id": "4108880000086001",
                    "name": "Patricia Boyle"
                },
                "modified_time": "2016-04-28T17:59:21+05:30",
                "created_time": "2016-04-28T17:59:21+05:30"
            },
            "status": "success",
            "code": "SUCCESS"
        }
    ]
}			

Sample Request: To Update a Lead


				Syntax:
<variable> =zoho.crm.updateRecord(<module_name>, <record_ID>, <record_value>, [<query_value>], [<connection>]);
mandatory: module_name, record_id

Sample Request:
leadinfo = 
 {
 "Company":"Zylker", 
 "Last_Name":"Stewart", 
 "Phone":"9876XXXXXX",
 "Email":"stewart@zylker.com"
 }; 

response = zoho.crm.updateRecord("Leads",23033XXXXXXXXXXXXXX,leadinfo);			

Sample Response


				{  
   "Modified_Time":"2018-03-26T15:17:39+05:30",
   "Modified_By":{  
      "name":"Patricia Boyle",
      "id":"29383XXXXXXXXXXXXXX"
   },
   "Created_Time":"2018-03-26T14:39:28+05:30",
   "id":"29383XXXXXXXXXXXXXX",
   "Created_By":{  
      "name":"Patricia Boyle",
      "id":"29383XXXXXXXXXXXXXX"
   }
}			

Sample Request


				public void UpdateRecords()
{
    List<ZCRMRecord> listRecord = new List<ZCRMRecord>();
    ZCRMRecord record;

    record = new ZCRMRecord("Invoices"); //To get ZCRMRecord instance
    record.SetFieldValue("id", 3372164000001904002);
    record.SetFieldValue("Subject", "UpdateInvoice4"); //This method use to set FieldApiName and value similar to all other FieldApis and Custom field
    record.SetFieldValue("Account_Name", 3372164000001855101);
    record.SetFieldValue("Company", "KK");
    record.SetFieldValue("Last_Name", "User");
    record.SetFieldValue("Customfield", "CustomFieldValue");
    record.SetFieldValue("Price_Book_Name", "Price_Book_Name");

    /** Following methods are being used only by Inventory modules */
    ZCRMPriceBookPricing pricing;

    pricing = new ZCRMPriceBookPricing
    {
        ToRange = 5,
        FromRange = 1,
        Discount = 0
    };
    record.AddPriceDetail(pricing);

    pricing = new ZCRMPriceBookPricing
    {
        ToRange = 11,
        FromRange = 6,
        Discount = 1
    };
    record.AddPriceDetail(pricing);

    pricing = new ZCRMPriceBookPricing
    {
        ToRange = 17,
        FromRange = 12,
        Discount = 2
    };
    record.AddPriceDetail(pricing);

    pricing = new ZCRMPriceBookPricing
    {
        ToRange = 23,
        FromRange = 18,
        Discount = 3
    };
    record.AddPriceDetail(pricing);

    record.SetFieldValue("Pricing_Model", "Flat"); 
    ZCRMTax linetax;
    linetax = ZCRMTax.GetInstance("Sales Tax");
    linetax.Percentage = 12.5;
    record.AddTax(linetax);

    ZCRMRecord product = ZCRMRecord.GetInstance("Products", 3372164000000190001); // product instance

    ZCRMInventoryLineItem lineItem = new ZCRMInventoryLineItem(product)
    {
        Description = "Product_description", //To set line item description
        Discount = 5, //To set line item discount
        ListPrice = 100 //To set line item list price

    }; //To get ZCRMInventoryLineItem instance
    lineItem.DiscountPercentage = 10;
    ZCRMTax taxInstance = ZCRMTax.GetInstance("Sales Tax"); //To get ZCRMTax instance
    taxInstance.Percentage = 2; //To set tax percentage
    taxInstance.Value = 50; //To set tax value
    lineItem.AddLineTax(taxInstance); //To set line tax to line item

    taxInstance = ZCRMTax.GetInstance("Vat");
    taxInstance.Percentage = 12;
    taxInstance.Value = 50;

    lineItem.AddLineTax(taxInstance);
    lineItem.Quantity = 200; //To set product quantity to this line item

    record.AddLineItem(lineItem); //The line item set to the record object
    /** End Inventory **/

    listRecord.Add(record);


    record = new ZCRMRecord("Invoices"); //To get ZCRMRecord instance
    record.SetFieldValue("id", 3372164000001904001);
    record.SetFieldValue("Subject", "UpdateInvoice4"); //This method use to set FieldApiName and value similar to all other FieldApis and Custom field
    record.SetFieldValue("Account_Name", 3372164000001855101);
    record.SetFieldValue("Company", "KK");
    record.SetFieldValue("Last_Name", "User");
    record.SetFieldValue("Customfield", "CustomFieldValue");
    record.SetFieldValue("Price_Book_Name", "Price_Book_Name");

    /** Following methods are being used only by Inventory modules */
    ZCRMPriceBookPricing pricing1;

    pricing1 = new ZCRMPriceBookPricing
    {
        ToRange = 5,
        FromRange = 1,
        Discount = 0
    };
    record.AddPriceDetail(pricing1);

    pricing1 = new ZCRMPriceBookPricing
    {
        ToRange = 11,
        FromRange = 6,
        Discount = 1
    };
    record.AddPriceDetail(pricing1);

    pricing1 = new ZCRMPriceBookPricing
    {
        ToRange = 17,
        FromRange = 12,
        Discount = 2
    };
    record.AddPriceDetail(pricing1);

    pricing1 = new ZCRMPriceBookPricing
    {
        ToRange = 23,
        FromRange = 18,
        Discount = 3
    };
    record.AddPriceDetail(pricing1);

    record.SetFieldValue("Pricing_Model", "Flat");
    linetax = ZCRMTax.GetInstance("Sales Tax");
    linetax.Percentage = 12.5;
    record.AddTax(linetax);

    ZCRMRecord product1 = ZCRMRecord.GetInstance("Products", 3372164000000190001); // product instance

    ZCRMInventoryLineItem lineItem1 = new ZCRMInventoryLineItem(product1)
    {
        Description = "Product_description", //To set line item description
        Discount = 5, //To set line item discount
        ListPrice = 100 //To set line item list price

    }; //To get ZCRMInventoryLineItem instance
    lineItem1.DiscountPercentage = 10;
    ZCRMTax taxInstance11 = ZCRMTax.GetInstance("Sales Tax"); //To get ZCRMTax instance
    taxInstance11.Percentage = 2; //To set tax percentage
    taxInstance11.Value = 50; //To set tax value
    lineItem1.AddLineTax(taxInstance11); //To set line tax to line item

    taxInstance11 = ZCRMTax.GetInstance("Vat");
    taxInstance11.Percentage = 12;
    taxInstance11.Value = 50;

    lineItem1.AddLineTax(taxInstance11);
    lineItem1.Quantity = 500; //To set product quantity to this line item

    record.AddLineItem(lineItem1); //The line item set to the record object
    /** End Inventory **/

    listRecord.Add(record);

    ZCRMModule moduleIns = ZCRMModule.GetInstance("Invoices"); //To get the Module instance
    BulkAPIResponse<ZCRMRecord> responseIns = moduleIns.UpdateRecords(listRecord); //To call the Update record method
    Console.WriteLine("HTTP Status Code:" + responseIns.HttpStatusCode); //To get Update record http response code
    foreach (EntityResponse response in responseIns.BulkEntitiesResponse)
    {
        Console.WriteLine("Status:" + response.Status); //To get Update record response status
        Console.WriteLine("Message:" + response.Message); //To get Update record response message
        Console.WriteLine("Details:" + response.ResponseJSON); //To get Update record response details
        ZCRMRecord record1 = (ZCRMRecord)response.Data;
        Console.WriteLine(record1.EntityId); //To get inserted record id
        Console.WriteLine(record1.CreatedTime);
        Console.WriteLine(record1.ModifiedTime);
        ZCRMUser CreatedBy = record1.CreatedBy;
        if(CreatedBy != null)
        {
            Console.WriteLine(CreatedBy.Id);
            Console.WriteLine(CreatedBy.FullName);
        }
        ZCRMUser ModifiedBy = record1.ModifiedBy;
        if (ModifiedBy != null)
        {
            Console.WriteLine(ModifiedBy.Id);
            Console.WriteLine(ModifiedBy.FullName);
        }
    }
}			

Sample Response


				{
    "data": [
       {
            "message": "record updated",
            "details": {
                "created_by": {
                    "id": "4108880000086001",
                    "name": "Patricia Boyle"
                },
                "id": "410888000000478065",
                "modified_by": {
                    "id": "4108880000086001",
                    "name": "Patricia Boyle"
                },
                "modified_time": "2016-04-28T17:59:21+05:30",
                "created_time": "2016-04-28T17:59:21+05:30"
            },
            "status": "success",
            "duplicate_field": "Email",
            "action": "update",
            "code": "SUCCESS"
        },
       {
            "message": "record updated",
            "details": {
                "created_by": {
                    "id": "4108880000086001",
                    "name": "Patricia Boyle"
                },
                "id": "4108880000478066",
                "modified_by": {
                    "id": "4108880000086001",
                    "name": "Patricia Boyle"
                },
                "modified_time": "2016-04-28T17:59:21+05:30",
                "created_time": "2016-04-28T17:59:21+05:30"
            },
            "status": "success",
            "duplicate_field": "Email",
            "action": "update",
            "code": "SUCCESS"
        }
    ]
}