How To Update And Delete Lead Using Zoho CRM In ASP.NET MVC

Introduction

In this article, we will learn how to update and delete lead using Zoho CRM in ASP.NET MVC Web application.

Let’s begin

Please read this article first of all here.

If you have not seen How to Get All Leads Data then I recommend you to see that first. in that article, I described how to get all leads data using Zoho CRM.

C# Code Example

Open the HomeController.cs file and add the below code in it.

Update Lead

public void UpdateLead()
 {
         ZCRMModule moduleInsAccounr = ZCRMModule.GetInstance("accounts"); //module api name
         BulkAPIResponse<ZCRMRecord> responseAccount = moduleInsAccounr.GetRecords();
         List<ZCRMRecord> relatedListsAccount = responseAccount.BulkData;

         List<ZCRMRecord> listRecord = new List<ZCRMRecord>();
         ZCRMRecord record;

         record = new ZCRMRecord("leads"); //To get ZCRMRecord instance
         record.SetFieldValue("id", lead id);
         record.SetFieldValue("Email", "test@gmail.com"); //This method use to set FieldApiName and value similar to all other FieldApis and Custom field
         record.SetFieldValue(relatedListsAccount[0].CreatedBy.FullName, relatedListsAccount[0].CreatedBy.Id);
         record.SetFieldValue("Company", "KK1");
         record.SetFieldValue("Last_Name", "User1");
         record.SetFieldValue("First_Name", "test1");
         record.SetFieldValue("Phone", "02122020");
         listRecord.Add(record);

         ZCRMModule moduleInslead = ZCRMModule.GetInstance("leads"); //To get the Module instance
         BulkAPIResponse<ZCRMRecord> responseIns = moduleInslead.UpdateRecords(listRecord); //To call the Update record method
         Console.WriteLine("HTTP Status Code:" + responseIns.HttpStatusCode);
     
 }

Delete Lead

public void DeleteLead()
{
    ZCRMRecord record = ZCRMRecord.GetInstance("leads", lead id);//module api name with record id
    APIResponse response1 = record.Delete();
}

If you have any questions or issues about this article, please let me know and you can find more details here.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe

Select Categories