private bool RegisterLead(UserProfile profile) { if (!Connected) { return(false); } if (profile.ADS_CRM_ID.HasValue) { throw new Exception("Profile already has a registered CRM ID."); } var newLead = new ZCRMRecord("Leads"); PopulateCRMLead(profile, newLead); try { var createResponse = newLead.Create(); if (createResponse.HttpStatusCode == APIConstants.ResponseCode.CREATED) { profile.ADS_CRM_ID = (createResponse.Data as ZCRMRecord).EntityId; return(true); } } catch (ZCRMException ex) { throw new Exception($"ZOHO Error: {ex.Message} ({JsonConvert.SerializeObject(ex.Data)})", ex); } return(false); }
public ZCRMRecord CreateLead(LeadRequest leadRequest) { ZCRMRecord record = ZCRMRecord.GetInstance(ZohoConstants.LEAD_MODULE_STRING, null); record.SetFieldValue("Last_Name", leadRequest.Name); //This method use to set FieldApiName and value similar to all other FieldApis and Custom field record.SetFieldValue("Email", leadRequest.Email); record.SetFieldValue("Description", leadRequest.Description); record.SetFieldValue("Email_Opt_Out", true); record.SetFieldValue("No_of_Employees", leadRequest.NumberOfEmployees); ZCRMUser owner = ZCRMUser.GetInstance(680990340);//User Id record.Owner = owner; APIResponse responseIns = record.Create();//To call the create record method ZCRMRecord record1 = (ZCRMRecord)responseIns.Data; return(record1); }