ASP.NET MVC

How To Get Related Records Data Using Zoho CRM In ASP.NET MVC

Introduction

In this article, we will learn how to get related records data 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 Create Campaigns using Zoho CRM then I recommend you to see that first. in that article, I described how to Create campaigns using Zoho CRM.

C# Code Example

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

public void GetRelatedListData()
 {
     
     try
     {
         ZCRMModule moduleIns = ZCRMModule.GetInstance("leads"); //module api name
         BulkAPIResponse<ZCRMRecord> responseLead = moduleIns.GetRecords();
         List<ZCRMRecord> relatedLists = responseLead.BulkData;

         ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", relatedLists[0].EntityId); //module api name with record id
         BulkAPIResponse<ZCRMRecord> response = recordIns.GetRelatedListRecords("campaigns"); //RelatedList api name
         List<ZCRMRecord> relatedRecordsLists = response.BulkData; //relatedRecordsLists - list of ZCRMRecord instance//relatedRecordsLists - list of ZCRMRecord instance
        
     }
     catch (Exception ex)
     {

        
     }
   
 }

 

Update Related Records

public void UpdatedRelatedData()
{
    try
    {
        ZCRMModule module = ZCRMModule.GetInstance("Leads");
        BulkAPIResponse<ZCRMRecord> responseLead = module.GetRecords();
        List<ZCRMRecord> records = responseLead.BulkData;

        ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", records[0].EntityId); //module api name with record id
        ZCRMModule modulecampaigns = ZCRMModule.GetInstance("Campaigns");
        BulkAPIResponse<ZCRMRecord> responseCampaigns = modulecampaigns.GetRecords();
        List<ZCRMRecord> recordsCampaigns = responseCampaigns.BulkData;
        ZCRMJunctionRecord relatedRecord = ZCRMJunctionRecord.GetInstance("Campaigns",Convert.ToInt64(recordsCampaigns[0].EntityId)); //RelatedList api name with RelatedList record id
        relatedRecord.SetRelatedDetails("Status", "active");
        APIResponse response = recordIns.AddRelation(relatedRecord);
        String recStatus = response.Status; //check status of the update relation
                                            //In the above example, lead with ID 337216400000 gets associated with the campaign with ID 33721640000001.
    }
    catch (Exception ex)
    {

       
    }
}

 

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

 

 

Sagar Rana

Sagar Rana is a Web Developer in Vision Infotech. He has strong skills and knowledge of ASP.NET C#, ASP.NET MVC, .Net Core, Jquery, JavaScript, WEB API, React.js, ADO.Net, Entity Framework, SQL and different integration like Xero, Stripe, Zoho CRM, Square, PayTM, PayKUN, RazorPay, Quickbook Desktop etc.

Recent Posts

Testing hk

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Operation

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

TETS NEW

test

2 years ago