C# SDKのサンプルコード - レコードの操作

特定のレコードの詳細の取得

/** Get a specific record */
public void GetRecord()
{
    ZCRMModule module = ZCRMModule.GetInstance("Leads");
    APIResponse response = module.GetRecord(538518000449026);
    ZCRMRecord record = (ZCRMRecord)response.Data;
    Console.WriteLine(record.EntityId); //To get record id
    Console.WriteLine(record.ModuleAPIName); //To get module api name
    Console.WriteLine(record.LookupLabel); //To get lookup object name

    ZCRMUser createdBy = record.CreatedBy;
    Console.WriteLine(createdBy.Id); //To get UserId who created the record
    Console.WriteLine(createdBy.FullName); //To get User name who created the record

    ZCRMUser modifiedBy = record.ModifiedBy;
    Console.WriteLine(modifiedBy.Id); //To get UserId who modified the record
    Console.WriteLine(modifiedBy.FullName); //To get User name who modified the record

    ZCRMUser owner = record.Owner;
    Console.WriteLine(owner.Id); //To get record OwnerId
    Console.WriteLine(owner.FullName);//To get record Owner name

    Console.WriteLine(record.CreatedTime); //To get record created time
    Console.WriteLine(record.ModifiedTime); //To get record modified time
    //Console.WriteLine(record.GetFieldValue("Last_Name")); //To get particular field value 

    if (record.Tags.Count > 0)
        {
            foreach (ZCRMTag tagnames in record.Tags)
            {
                Console.WriteLine(tagnames.Id);
                Console.WriteLine(tagnames.Name);
            }
            Console.WriteLine("\n\n");
        }
    Dictionary<string, object> recordData = record.Data; //Returns record as Dictionary

    //Console.WriteLine(record.PriceDetails);
    foreach (KeyValuePair<string, object> data in record.Data)
    {
        if (data.Value is ZCRMRecord recordValue) //If data.Value is ZCRMRecord instance 
        {
            Console.WriteLine(recordValue.EntityId); //To get record id
            Console.WriteLine(recordValue.ModuleAPIName); //To get module api name
            Console.WriteLine(recordValue.LookupLabel); //To get lookup object name
        }
        else if(data.Value is List<string>)
                {
                    Console.WriteLine(data.Key);
                    foreach (string tag in (List<string>)data.Value)
                {
                    Console.WriteLine(files.FileId);
                    Console.WriteLine(files.FileName);
                    Console.WriteLine(files.AttachmentId);
                    Console.WriteLine(files.EntityId);
                }
            Console.WriteLine("\n\n");
        }
        else if (data.Value is List<string>)
        {
            foreach (string tagnames in (List<string>)data.Value)
            {
                Console.WriteLine(tagnames);
            }
            Console.WriteLine("\n\n");
        }
        else //data.Value is not ZCRMRecord instance
        {
            Console.WriteLine(data.Key + "\t" + data.Value);
        }
    }
    Console.WriteLine("\n\n");

    /** Fields which start with "$" are considered to be property fields */
    //Console.WriteLine(record.GetProperty("$fieldName")); //To get a particular property value
    Dictionary<string, object> properties = record.Properties; //To get record properties as Dictionary
    foreach (KeyValuePair<string, object> property in properties)
    {
        if (property.Value is List<string>) //If value is an array
        {
            Console.WriteLine("\n\n" + property.Key);
            foreach (string data in (List<string>)property.Value)
            {
                Console.WriteLine(data + "\t");
            }
        }
        else if (property.Value is Dictionary<string, object>)
        {
            Console.WriteLine("\n\n" + property.Key);
            foreach (KeyValuePair<string, object> data in (Dictionary<string, object>)property.Value)
            {
                if (property.Value is Dictionary<string, object>)
                {
                    foreach (KeyValuePair<string, object> data1 in (Dictionary<string, object>)data.Value)
                    {
                        Console.WriteLine(data1.Key + "\t" + data1.Value);
                    }
                }
                else
                {
                    Console.WriteLine(data.Key + "\t" + data.Value);
                }
            }
        }
        else
        {
            Console.WriteLine(property.Key + "\t" + property.Value);
        }
    }

    //BulkAPIResponse<ZCRMRecord> relatedlist = record.GetRelatedListRecords("Products"); //To get Related records of a record
    ///** Related records is of type ZCRMRecord **/
    //List<ZCRMRecord> lists = relatedlist.BulkData; //To get related list data
    //foreach (ZCRMRecord rec in lists)
    //{
    //Console.WriteLine(rec.EntityId); //To get  record id
    //Console.WriteLine(rec.ModuleAPIName); //To get module api name
    //}

    BulkAPIResponse<ZCRMNote> noteResponse = record.GetNotes(); //To get record notes
    //BulkAPIResponse<ZCRMNote> noteResponse = record.GetNotes(1,10); //page, perPage.
    //BulkAPIResponse<ZCRMNote> noteResponse = record.GetNotes("title", CommonUtil.SortOrder.asc); //sortByField, sortOrder
    //BulkAPIResponse<ZCRMNote> noteResponse = record.GetNotes("title", CommonUtil.SortOrder.asc,1,10, "2019-12-25T04:00:00+02:00"); //sortByField, sortOrder, page, perPage and modifiedSince(Header)
    List<ZCRMNote> notes = noteResponse.BulkData;
    foreach (ZCRMNote note in notes)
    {
        Console.WriteLine(note.Id); //To get note id
        Console.WriteLine(note.Title); //To get note title
        Console.WriteLine(note.Content); //To get note content

        ZCRMRecord parentRecord = note.ParentRecord; //To get note's parent record
        Console.WriteLine(parentRecord.EntityId); //To get note's parent record id
        Console.WriteLine(parentRecord.ModuleAPIName); // To get note's parent record Module API name

        ZCRMUser noteCreatedBy = note.CreatedBy;
        Console.WriteLine(noteCreatedBy.Id); //To get UserId who created the notes
        Console.WriteLine(noteCreatedBy.FullName); //To get User name who created the notes

        ZCRMUser noteModifiedBy = note.ModifiedBy;
        Console.WriteLine(noteModifiedBy.Id); //To get UserId who modified the notes
        Console.WriteLine(noteModifiedBy.FullName); //To get User name who modified the notes

        ZCRMUser noteOwner = note.NotesOwner;
        Console.WriteLine(noteOwner.Id); //To get notes OwnerId
        Console.WriteLine(noteOwner.FullName); //To get notes Owner name

        Console.WriteLine(note.CreatedTime); //To get created time of the note
        Console.WriteLine(note.ModifiedTime); //To get modified time of the note

        List<ZCRMAttachment> noteAttachment = note.Attachments; //To get attachments of the note record
        if (noteAttachment != null) //check If attachments is empty/not
        {
            foreach (ZCRMAttachment attachment in noteAttachment)
            {
                Console.WriteLine(attachment.Id); //To get the note's attachment id
                Console.WriteLine(attachment.FileName); //To get the note's attachment file name
                Console.WriteLine(attachment.FileType); //To get the note's attachment file type
                Console.WriteLine(attachment.Size); //To get the note's attachment file size

                ZCRMRecord attachmentRecord = attachment.ParentRecord;
                Console.WriteLine(attachmentRecord.EntityId); //To get the note's parent record id
                Console.WriteLine(attachmentRecord.ModuleAPIName); //To get the record name

                ZCRMUser noteAttachmentCreatedBy = note.CreatedBy;
                Console.WriteLine(noteAttachmentCreatedBy.Id); // To get user_id who created the note's attachment
                Console.WriteLine(noteAttachmentCreatedBy.FullName); //To get user name who created the note's attachment

                ZCRMUser noteAttachmentModifiedBy = note.ModifiedBy;
                Console.WriteLine(noteAttachmentModifiedBy.Id); //To get user_id who modified the note's attachment
                Console.WriteLine(noteAttachmentModifiedBy.FullName); //To get user name who modified the note's attachment

                ZCRMUser noteAttachmentOwner = note.NotesOwner;
                Console.WriteLine(noteAttachmentOwner.Id); //To get the note's attachment owner id
                Console.WriteLine(noteAttachmentOwner.FullName); //To get the note's attachment owner name

                Console.WriteLine(attachment.CreatedTime); //To get attachment created time
                Console.WriteLine(attachment.ModifiedTime); //To get attachment modified time
            }
        }
    }

    BulkAPIResponse<ZCRMAttachment> attachmentResponse = record.GetAttachments(); //To get record's attachments 
    //BulkAPIResponse<ZCRMAttachment> attachmentResponse = record.GetAttachments(0,10, "019-12-25T04:00:00+02:00"); //page, perPage and modifiedSince(Header)
    List<ZCRMAttachment> attachments = attachmentResponse.BulkData; // To get list of attachments
    foreach (ZCRMAttachment attachment in attachments)
    {
        Console.WriteLine(attachment.Id); //To get the attachment id
        Console.WriteLine(attachment.FileName); //To get attachment file name
        Console.WriteLine(attachment.FileType); // To get attachment file type
        Console.WriteLine(attachment.Size); //To get attachment file size

        ZCRMRecord attachmentRecord = attachment.ParentRecord;
        Console.WriteLine(attachmentRecord.EntityId); //To get the parent record id
        Console.WriteLine(attachmentRecord.ModuleAPIName); //To get the parent record name

        ZCRMUser attachmentCreatedBy = attachment.CreatedBy;
        Console.WriteLine(attachmentCreatedBy.Id); // To get user_id who created the  attachment
        Console.WriteLine(attachmentCreatedBy.FullName); //To get user name who created the  attachment

        ZCRMUser attachmentModifiedBy = attachment.ModifiedBy;
        Console.WriteLine(attachmentModifiedBy.Id); //To get user_id who modified the attachment
        Console.WriteLine(attachmentModifiedBy.FullName); //To get user name who modified the attachment

        ZCRMUser noteAttachmentOwner = attachment.Owner;
        Console.WriteLine(noteAttachmentOwner.Id); //To get the attachment owner id
        Console.WriteLine(noteAttachmentOwner.FullName); //To get the attachment owner name

        Console.WriteLine(attachment.CreatedTime); //To get attachment created time
        Console.WriteLine(attachment.ModifiedTime); //To get attachment modified time

        FileAPIResponse fResponse = attachment.DownloadFile(); //To download the attachment file
        Console.WriteLine("File Name:" + fResponse.GetFileName()); // To get attachment file name
        Console.WriteLine("HTTP Status Code:" + fResponse.HttpStatusCode); //To get HTTP status code 
        Stream file = fResponse.GetFileAsStream(); //To get attachment file content
        CommonUtil.SaveStreamAsFile("/Users/Desktop/photo", file, fResponse.GetFileName()); //To write a new file using the same attachment name
    }


    ZCRMLayout layout = record.Layout; //To get record layout
    if (layout != null)
    {
        Console.WriteLine(layout.Id); //To get layout_id
        Console.WriteLine(layout.Name); //To get layout name 
    }

    /** Following methods are being used only by Inventory modules */
    List<ZCRMTax> taxlists = record.TaxList; //To get the tax list
    foreach (ZCRMTax tax in taxlists)
    {
        Console.WriteLine(tax.TaxName); //To get tax name
        Console.WriteLine(tax.Percentage); //To get tax percentage
        Console.WriteLine(tax.Value); //To get tax value
    }

    List<ZCRMInventoryLineItem> lineItems = record.LineItems; //To get list of line_items
    foreach (ZCRMInventoryLineItem lineItem in lineItems)
    {
        Console.WriteLine(lineItem.Id); //To get lineItem id
        Console.WriteLine(lineItem.ListPrice); //To get lineItem list price
        Console.WriteLine(lineItem.Quantity); //To get lineItem quantity
        Console.WriteLine(lineItem.Description); //To get lineItem description
        Console.WriteLine(lineItem.Total); //To get lineItem total amount
        Console.WriteLine(lineItem.Discount); //To get lineItem discount
        Console.WriteLine(lineItem.DiscountPercentage); //To get lineItem discount percentage
        Console.WriteLine(lineItem.TotalAfterDiscount); //To get lineItem amount after discount
        Console.WriteLine(lineItem.TaxAmount); //To get lineItem tax amount
        Console.WriteLine(lineItem.NetTotal); //To get lineItem net total amount
        Console.WriteLine(lineItem.UnitPrice); //To get lineItem unit price
        Console.WriteLine(lineItem.Product.EntityId); //To get line_item product's entity id
        Console.WriteLine(lineItem.Product.LookupLabel); //To get line_item product's lookup label

        List<ZCRMTax> linetaxs = lineItem.LineTax; //To get list of line_tax in lineItem
        foreach (ZCRMTax tax in linetaxs)
        {
            Console.WriteLine(tax.TaxName); //To get line tax name
            Console.WriteLine(tax.Percentage); //To get line tax percentage
            Console.WriteLine(tax.Value); //To get line tax value
        }
    }

    List<ZCRMPriceBookPricing> pricedetails = record.PriceDetails; //To get the price details array
    foreach (ZCRMPriceBookPricing pricedetail in pricedetails)
    {
        Console.WriteLine(pricedetail.Id); //To get the record's priceId
        Console.WriteLine(pricedetail.ToRange); //To get the price detail record's to_range
        Console.WriteLine(pricedetail.FromRange); //To get the price detail record's from_range
        Console.WriteLine(pricedetail.Discount); //To get the price detail record's discount
    }
    /**  End Inventory **/

    /** Following method is used only by 'Events' module */
    List<ZCRMEventParticipant> participants = record.Participants; //To get Event record's participants
    foreach (ZCRMEventParticipant participant in participants)
    {
        Console.WriteLine(participant.Id); //To get the record's participant id
        Console.WriteLine(participant.Name); //To get the record's participant name
        Console.WriteLine(participant.Email);//To get the record's participant email
        Console.WriteLine(participant.Type); //To get the record's participant type
        Console.WriteLine(participant.IsInvited); //To check if the record's participant(s) are invited or not
        Console.WriteLine(participant.Status); //To get the record's participants' status
    }
     End Event 
}
 
レコードの作成

/** Insert a specific record */
public void InsertRecord()
{
    ZCRMRecord record = new ZCRMRecord("Leads"); //To get ZCRMRecord instance
    record.SetFieldValue("Subject", "UpdateInvoice4"); //This method use to set FieldApiName and value similar to all other FieldApis and Custom field 
    record.SetFieldValue("Account_Name", 3372164001855101);
    record.SetFieldValue("Company", "KK");
    record.SetFieldValue("Last_Name", "User");
    record.SetFieldValue("Customfield", "CustomFieldValue");
    record.SetFieldValue("Price_Book_Name", "Price_Book_Name");
    
    //Following methods are used to upload a file to a field
    
    List<ZCRMFiles> fileObjects = new List<ZCRMFiles>();
    ZCRMFiles file = ZCRMFiles.GetInstance("aexxxxxxxxxx732e26505e22e", null);
    fileObjects.Add(file);
    file = ZCRMFiles.GetInstance("aexxxxxxxxxx732e26505e22e", null);
    fileObjects.Add(file);
    record.SetFieldValue("File_Upload", fileObjects);

    /** 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");
    ZCRMTax linetax = ZCRMTax.GetInstance("Sales Tax");
    linetax.Percentage = 12.5;
    record.AddTax(linetax);

    ZCRMRecord product1 = ZCRMRecord.GetInstance("Products", 3372164000190001); // 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 **/
    List<string> trigger = new List<string>() { "workflow", "approval", "blueprint" };
    string larID = "3477061000004353013";
    APIResponse response = record.Create(trigger, larID); //To call the Update record method

    ZCRMRecord record1 = (ZCRMRecord)response.Data;

    Console.WriteLine("EntityId:" + record1.EntityId); //To get update record id
    Console.WriteLine(record1.ModifiedTime);
    Console.WriteLine(record1.CreatedTime);
    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);
    }
    Console.WriteLine("HTTP Status Code:" + response.HttpStatusCode); //To get Update record http response code
    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
}
 
レコードの更新

/** Update  a specific record */
public void UpdateRecord()
{
    ZCRMRecord record = ZCRMRecord.GetInstance("Products", 538518000440452); //To get ZCRMRecord instance
    record.SetFieldValue("Subject", "UpdateInvoice4"); //This method use to set FieldApiName and value similar to all other FieldApis and Custom field 
    record.SetFieldValue("Account_Name", 3372164001855101);
    record.SetFieldValue("Company", "KK");
    record.SetFieldValue("Last_Name", "User");
    record.SetFieldValue("Customfield", "CustomFieldValue");
    record.SetFieldValue("Price_Book_Name", "Price_Book_Name");

    ZCRMRecord lookup = ZCRMRecord.GetInstance("Vendors", 538518000440472);// vendor module api name with its record id
    record.SetFieldValue("Vendor_Name", lookup);
    
    //Following methods are used to update or delete a file uploaded to a field
    
    List<ZCRMFiles> fileObjects = new List<ZCRMFiles>();
    ZCRMFiles file = ZCRMFiles.GetInstance(null, null);
    file.AttachmentId = "3477xxxxxx4016";
    file.Delete = true;
    fileObjects.Add(file);
    file = ZCRMFiles.GetInstance(null, null);
    file.AttachmentId = "34770xxxxx4017";
    file.Delete = true;
    fileObjects.Add(file);
    file = ZCRMFiles.GetInstance("ae9xxxxxxxxxx1ce94b962", null);
    fileObjects.Add(file);
    record.SetFieldValue("File_Upload", fileObjects);

    /** 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");
    ZCRMTax linetax = ZCRMTax.GetInstance("Sales Tax");
    linetax.Percentage = 12.5;
    record.AddTax(linetax);

    ZCRMRecord product1 = ZCRMRecord.GetInstance("Products", 3372164000190001); // 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 **/
    List<string> trigger = new List<string>() { "workflow", "approval", "blueprint" };
    APIResponse response = record.Update(trigger); //To call the Update record method

    ZCRMRecord record1 = (ZCRMRecord)response.Data;

    Console.WriteLine("EntityId:" + record1.EntityId); //To get update 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);
    }
    Console.WriteLine("HTTP Status Code:" + response.HttpStatusCode); //To get Update record http response code
    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
}
 
レコードの削除

/** Delete a specific record */
public void DeleteRecord()
{
    /** Delete a specific record */
    ZCRMRecord record = ZCRMRecord.GetInstance("Vendors", 538518000440472);//module api name with record id
    APIResponse response = record.Delete();
    Console.WriteLine("Status:" + response.Status); //To get delete record response status
    Console.WriteLine("Message:" + response.Message); //To get delete record response message
    Console.WriteLine("Details:" + response.ResponseJSON); //To get delete record response details
    ZCRMRecord record1 = (ZCRMRecord)response.Data;
    Console.WriteLine(record1.EntityId); //To get inserted record id
    Console.WriteLine(record1.ModuleAPIName);
}
 
レコードの変換

/** Convert Lead */
public void ConvertLead()
{
    /** Convert Lead */
    ZCRMRecord record = ZCRMRecord.GetInstance("Leads", 538518000451020); //module api name with record id
    ZCRMRecord potentialRecord = new ZCRMRecord("Deals"); // module api name
    potentialRecord.SetFieldValue("Stage", "Qualification");
    potentialRecord.SetFieldValue("Closing_Date", "2019-01-25");
    potentialRecord.SetFieldValue("Deal_Name", "Deal_Name");
    ZCRMUser user = ZCRMUser.GetInstance(538518000231013);
    Dictionary<string, long> response = record.Convert(potentialRecord, user); // response is KeyValuePair 
    foreach(KeyValuePair<string, long> data in response)
    {
        Console.WriteLine(data.Key + ":" + data.Value);
    }
}
 
レコード内のメモ
メモの取得

/** Get specific notes data */
public void GetNotes()
{
    /** Get specific notes data */
    ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 538518000449026); //module api name with record id
    BulkAPIResponse<ZCRMNote> response = recordIns.GetNotes();
    List<ZCRMNote> notes = response.BulkData; //notes - list of ZCRMNote instance
    foreach (ZCRMNote note in notes)
    {
        Console.WriteLine(note.Id);
        Console.WriteLine(note.Title);
        Console.WriteLine(note.Content);
        ZCRMUser CreatedBy = note.CreatedBy;
        if(CreatedBy!=null)
        {
            Console.WriteLine(CreatedBy.Id);
            Console.WriteLine(CreatedBy.FullName);
        }

        Console.WriteLine(note.CreatedTime);
        Console.WriteLine(note.ModifiedTime);

        ZCRMUser ModifiedBy = note.ModifiedBy;
        if (ModifiedBy != null)
        {
            Console.WriteLine(ModifiedBy.Id);
            Console.WriteLine(ModifiedBy.FullName);
        }

        ZCRMUser NotesOwner = note.NotesOwner;
        if (NotesOwner != null)
        {
            Console.WriteLine(NotesOwner.Id);
            Console.WriteLine(NotesOwner.FullName);
        }

        ZCRMRecord ParentRecord = note.ParentRecord;
        Console.WriteLine(ParentRecord.EntityId);
        Console.WriteLine(ParentRecord.ModuleAPIName);

        List<ZCRMAttachment> noteAttachment = note.Attachments; //To get attachments of the note record
        if (noteAttachment != null) //check If attachments is empty/not
        {
            foreach (ZCRMAttachment attachment in noteAttachment)
            {
                Console.WriteLine(attachment.Id); //To get the note's attachment id
                Console.WriteLine(attachment.FileName); //To get the note's attachment file name
                Console.WriteLine(attachment.FileType); //To get the note's attachment file type
                Console.WriteLine(attachment.Size); //To get the note's attachment file size

                ZCRMRecord attachmentRecord = attachment.ParentRecord;
                Console.WriteLine(attachmentRecord.EntityId); //To get the note's parent record id
                Console.WriteLine(attachmentRecord.ModuleAPIName); //To get the record name

                ZCRMUser noteAttachmentCreatedBy = note.CreatedBy;
                Console.WriteLine(noteAttachmentCreatedBy.Id); // To get user_id who created the note's attachment
                Console.WriteLine(noteAttachmentCreatedBy.FullName); //To get user name who created the note's attachment

                ZCRMUser noteAttachmentModifiedBy = note.ModifiedBy;
                Console.WriteLine(noteAttachmentModifiedBy.Id); //To get user_id who modified the note's attachment
                Console.WriteLine(noteAttachmentModifiedBy.FullName); //To get user name who modified the note's attachment

                ZCRMUser noteAttachmentOwner = note.NotesOwner;
                Console.WriteLine(noteAttachmentOwner.Id); //To get the note's attachment owner id
                Console.WriteLine(noteAttachmentOwner.FullName); //To get the note's attachment owner name

                Console.WriteLine(attachment.CreatedTime); //To get attachment created time
                Console.WriteLine(attachment.ModifiedTime); //To get attachment modified time
            }
        }
    }
}
 
メモの追加

/** Create specific notes */
public void AddNote()
{
    ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 538518000449026); //module api name with record id
    ZCRMNote note = new ZCRMNote(recordIns);
    note.Content = "test msg";
    note.Title = "test class notes";
    APIResponse response = recordIns.AddNote(note);
    ZCRMNote createdNote = (ZCRMNote)response.Data;
    Console.WriteLine(createdNote.Id);
    Console.WriteLine(createdNote.CreatedTime);
    Console.WriteLine(createdNote.ModifiedTime);
    Console.WriteLine(createdNote.Title);
    Console.WriteLine(createdNote.Content);

    Console.WriteLine(response.Status);
    Console.WriteLine(response.Message);
}
 
メモの更新

/** Update notes */
public void UpdateNote()
{
    ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 538518000449026); //module api name with record id
    ZCRMNote note = ZCRMNote.GetInstance(recordIns, 538518000449095); //record instance with note id
    note.Content = "update message";
    APIResponse response = recordIns.UpdateNote(note);
    ZCRMNote updatedNote = (ZCRMNote)response.Data;
    Console.WriteLine(updatedNote.Id);
    Console.WriteLine(updatedNote.CreatedTime);
    Console.WriteLine(updatedNote.ModifiedTime);
    Console.WriteLine(updatedNote.Title);
    Console.WriteLine(updatedNote.Content);

    Console.WriteLine(response.Status);
    Console.WriteLine(response.Message);
}
 
メモの削除

/** Delete specific notes */
public void DeleteNote()
{
    ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 538518000449026); //module api name with record id
    ZCRMNote note = ZCRMNote.GetInstance(recordIns, 538518000449095); //record instance with note id
    APIResponse response = recordIns.DeleteNote(note);
    Console.WriteLine(response.Status);
    Console.WriteLine(response.Message);
}
 
レコード内のファイルと添付
添付ファイルの取得

/** Get list of attachments */
public void GetAllAttachments()
{
    /** Get list of attachments */
    ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 538518000449026); //module api name with record id
    BulkAPIResponse<ZCRMAttachment> response = recordIns.GetAttachments();
    List<ZCRMAttachment> attachments = response.BulkData; //attachments - list of ZCRMAttachment instance
    foreach (ZCRMAttachment attachment in attachments)
    {
        Console.WriteLine(attachment.Id); //To get the attachment id
        Console.WriteLine(attachment.FileName); //To get attachment file name
        Console.WriteLine(attachment.FileType); // To get attachment file type
        Console.WriteLine(attachment.Size); //To get attachment file size

        ZCRMRecord attachmentRecord = attachment.ParentRecord;
        Console.WriteLine(attachmentRecord.EntityId); //To get the parent record id
        Console.WriteLine(attachmentRecord.ModuleAPIName); //To get the parent record name

        ZCRMUser attachmentCreatedBy = attachment.CreatedBy;
        Console.WriteLine(attachmentCreatedBy.Id); // To get user_id who created the  attachment
        Console.WriteLine(attachmentCreatedBy.FullName); //To get user name who created the  attachment

        ZCRMUser attachmentModifiedBy = attachment.ModifiedBy;
        Console.WriteLine(attachmentModifiedBy.Id); //To get user_id who modified the attachment
        Console.WriteLine(attachmentModifiedBy.FullName); //To get user name who modified the attachment

        ZCRMUser noteAttachmentOwner = attachment.Owner;
        Console.WriteLine(noteAttachmentOwner.Id); //To get the attachment owner id
        Console.WriteLine(noteAttachmentOwner.FullName); //To get the attachment owner name

        Console.WriteLine(attachment.CreatedTime); //To get attachment created time
        Console.WriteLine(attachment.ModifiedTime); //To get attachment modified time

        FileAPIResponse fResponse = attachment.DownloadFile(); //To download the attachment file
        Console.WriteLine("File Name:" + fResponse.GetFileName()); // To get attachment file name
        Console.WriteLine("HTTP Status Code:" + fResponse.HttpStatusCode); //To get HTTP status code 
        Stream file = fResponse.GetFileAsStream(); //To get attachment file content
        CommonUtil.SaveStreamAsFile("/Users/test/Desktop/photo", file, fResponse.GetFileName()); //To write a new file using the same attachment name
    }
}
 
添付ファイルのアップロード

/** Upload an attachment */
public void UploadAttachment()
{
    /** Upload an attachment */
    ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 538518000449026);//module api name with record id
    APIResponse response = recordIns.UploadAttachment("/Users/Desktop/testreport/index.htm");
    ZCRMAttachment attachment = (ZCRMAttachment)response.Data;
    Console.WriteLine(attachment.Id); //To get the attachment id
    Console.WriteLine(attachment.FileName); //To get attachment file name
    Console.WriteLine(attachment.FileType); // To get attachment file type
    Console.WriteLine(attachment.Size); //To get attachment file size

    ZCRMRecord attachmentRecord = attachment.ParentRecord;
    Console.WriteLine(attachmentRecord.EntityId); //To get the parent record id
    Console.WriteLine(attachmentRecord.ModuleAPIName); //To get the parent record name

    ZCRMUser attachmentCreatedBy = attachment.CreatedBy;
    Console.WriteLine(attachmentCreatedBy.Id); // To get user_id who created the  attachment
    Console.WriteLine(attachmentCreatedBy.FullName); //To get user name who created the  attachment

    ZCRMUser attachmentModifiedBy = attachment.ModifiedBy;
    Console.WriteLine(attachmentModifiedBy.Id); //To get user_id who modified the attachment
    Console.WriteLine(attachmentModifiedBy.FullName); //To get user name who modified the attachment

    ZCRMUser noteAttachmentOwner = attachment.Owner;
    Console.WriteLine(noteAttachmentOwner.Id); //To get the attachment owner id
    Console.WriteLine(noteAttachmentOwner.FullName); //To get the attachment owner name

    Console.WriteLine(attachment.CreatedTime); //To get attachment created time
    Console.WriteLine(attachment.ModifiedTime); //To get attachment modified time

    FileAPIResponse fResponse = attachment.DownloadFile(); //To download the attachment file
    Console.WriteLine("File Name:" + fResponse.GetFileName()); // To get attachment file name
    Console.WriteLine("HTTP Status Code:" + fResponse.HttpStatusCode); //To get HTTP status code 
    Stream file = fResponse.GetFileAsStream(); //To get attachment file content
    CommonUtil.SaveStreamAsFile("/Users/Desktop/photo", file, fResponse.GetFileName()); //To write a new file using the same attachment name
}
 

/** Upload an attachment link */
public void UploadAttachmentLink()
{
    ZCRMRecord record = ZCRMRecord.GetInstance("Leads", 538518000449026);
    APIResponse response = record.UploadLinkAsAttachment("(attachment url)");
    ZCRMAttachment attachment = (ZCRMAttachment)response.Data;
    Console.WriteLine(attachment.Id); //To get the attachment id
    Console.WriteLine(attachment.FileName); //To get attachment file name
    Console.WriteLine(attachment.FileType); // To get attachment file type
    Console.WriteLine(attachment.Size); //To get attachment file size

    ZCRMRecord attachmentRecord = attachment.ParentRecord;
    Console.WriteLine(attachmentRecord.EntityId); //To get the parent record id
    Console.WriteLine(attachmentRecord.ModuleAPIName); //To get the parent record name

    ZCRMUser attachmentCreatedBy = attachment.CreatedBy;
    Console.WriteLine(attachmentCreatedBy.Id); // To get user_id who created the  attachment
    Console.WriteLine(attachmentCreatedBy.FullName); //To get user name who created the  attachment

    ZCRMUser attachmentModifiedBy = attachment.ModifiedBy;
    Console.WriteLine(attachmentModifiedBy.Id); //To get user_id who modified the attachment
    Console.WriteLine(attachmentModifiedBy.FullName); //To get user name who modified the attachment

    ZCRMUser noteAttachmentOwner = attachment.Owner;
    Console.WriteLine(noteAttachmentOwner.Id); //To get the attachment owner id
    Console.WriteLine(noteAttachmentOwner.FullName); //To get the attachment owner name

    Console.WriteLine(attachment.CreatedTime); //To get attachment created time
    Console.WriteLine(attachment.ModifiedTime); //To get attachment modified time

    Console.WriteLine(response.Status);
    Console.WriteLine(response.Message);
}
 
添付ファイルのダウンロード

/** Download an attachment */
public void DownloadAttachment()
{
    /** Download an attachment */
    ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 538518000449026); //module api name with record id
    FileAPIResponse response = recordIns.DownloadAttachment(538518000451099); //attachmentID
    Stream file = response.GetFileAsStream();
    CommonUtil.SaveStreamAsFile("/Users/Desktop/photo", file, response.GetFileName());
    Console.WriteLine(response.Status);
}
 
添付ファイルの削除

/** Delete attachments */
public void DeleteAttachment()
{
    /** Delete attachments */
    ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 538518000449026); //module api name with record id
    APIResponse response = recordIns.DeleteAttachment(538518000451099); //attachmentID
    Console.WriteLine(response.ResponseJSON); //attachment is JArray
}
 
レコード内の画像
写真のアップロード

/** Upload a photo */
public void UploadPhoto()
{
    /** Upload a photo */
    ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 538518000449026); //module apiname with record id
    APIResponse response = recordIns.UploadPhoto("/Users/Desktop/zoho-crm.jpg");
    Console.WriteLine(response.ResponseJSON); //photo is JArray
}
 
写真のダウンロード

/** Download a photo */
public void DownloadPhoto()
{
    /** Download a photo */
    ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 538518000449026); //module apiname with record id
    FileAPIResponse response = recordIns.DownloadPhoto();
    Stream photoStream = response.GetFileAsStream();
    CommonUtil.SaveStreamAsFile("/Users/Desktop/test", photoStream, response.GetFileName());
    Console.WriteLine(response.Status);
}
 
写真の削除

/** Delete a photo */
public void DeletePhoto()
{
    /** Delete a photo */
    ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 538518000449026); //module apiname with record id
    APIResponse response = recordIns.DeletePhoto();
    Console.WriteLine(response.Status);
}
 
レコードの連結
レコード間の関連付けの追加

/** Update related records */
public void AddRelation()
{
    ZCRMRecord recordIns = ZCRMRecord.GetInstance("Products", 538518000440452); //module api name with record id
    ZCRMJunctionRecord relatedRecord = ZCRMJunctionRecord.GetInstance("Price_Books", 538518000443803); //RelatedList api name with RelatedList record id
    relatedRecord.SetRelatedDetails("list_price", 50);
    APIResponse response = recordIns.AddRelation(relatedRecord);
    String recStatus = response.Status; //check status of the update relation
    Console.WriteLine(recStatus);
    Console.WriteLine(response.Message);
    Console.WriteLine(response.HttpStatusCode);
    Console.WriteLine(response.ResponseJSON);
}
 
レコード間の関連付けの削除(リンク解除)

/** Delink */
public void DeleteRelation()
{
    ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 538518000449026);//module api name with record id
    ZCRMJunctionRecord relatedRecord = ZCRMJunctionRecord.GetInstance("Campaigns", 538518000440462); //RelatedList api name with RelatedList record id
    APIResponse response = recordIns.DeleteRelation(relatedRecord);
    String recStatus = response.Status; //check status of the delete relation
    Console.WriteLine(recStatus);
    Console.WriteLine(response.Message);
    Console.WriteLine(response.HttpStatusCode);
    Console.WriteLine(response.ResponseJSON);
}
 

/** Get related records */
public void GetRelatedListRecords()
{
    ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 53851800449026); //module api name with record id
    BulkAPIResponse<ZCRMRecord> response = recordIns.GetRelatedListRecords("Products"); //RelatedList api name
    List<ZCRMRecord> relatedRecordsLists = response.BulkData; //relatedRecordsLists - list of ZCRMRecord instance
    foreach (ZCRMRecord record in relatedRecordsLists)
    {
        Console.WriteLine(record.EntityId); //To get record id
        Console.WriteLine(record.ModuleAPIName); //To get module api name
        Console.WriteLine(record.LookupLabel); //To get lookup object name

        ZCRMUser createdBy = record.CreatedBy;
        Console.WriteLine(createdBy.Id); //To get UserId who created the record
        Console.WriteLine(createdBy.FullName); //To get User name who created the record

        ZCRMUser modifiedBy = record.ModifiedBy;
        Console.WriteLine(modifiedBy.Id); //To get UserId who modified the record
        Console.WriteLine(modifiedBy.FullName); //To get User name who modified the record

        ZCRMUser owner = record.Owner;
        Console.WriteLine(owner.Id); //To get record OwnerId
        Console.WriteLine(owner.FullName);//To get record Owner name

        Console.WriteLine(record.CreatedTime); //To get record created time
        Console.WriteLine(record.ModifiedTime); //To get record modified time
        //Console.WriteLine(record.GetFieldValue("Last_Name")); //To get particular field value 

        if (record.Tags.Count > 0)
        {
            foreach (ZCRMTag tagnames in record.Tags)
            {
                Console.WriteLine(tagnames.Id);
                Console.WriteLine(tagnames.Name);
            }
            Console.WriteLine("\n\n");
        }

        Dictionary<string, object> recordData = record.Data; //Returns record as Dictionary

        //Console.WriteLine(record.PriceDetails);
        foreach (KeyValuePair<string, object> data in record.Data)
        {
            if (data.Value is ZCRMRecord recordValue) //If data.Value is ZCRMRecord instance 
            {
                Console.WriteLine(recordValue.EntityId); //To get record id
                Console.WriteLine(recordValue.ModuleAPIName); //To get module api name
                Console.WriteLine(recordValue.LookupLabel); //To get lookup object name
            }
            else if (data.Value is List<string>)
            {
                Console.WriteLine(data.Key);
                foreach (string tag in (List<string>)data.Value)
                {
                    Console.WriteLine(tag);
                }
                Console.WriteLine("\n\n");
            }
            else //data.Value is not ZCRMRecord instance
            {
                Console.WriteLine(data.Key + "\t" + data.Value);
            }
        }
        Console.WriteLine("\n\n");

        /** Fields which start with "$" are considered to be property fields */
        //Console.WriteLine(record.GetProperty("$fieldName")); //To get a particular property value
        Dictionary<string, object> properties = record.Properties; //To get record properties as Dictionary
        foreach (KeyValuePair<string, object> property in properties)
        {
            if (property.Value is List<string>) //If value is an array
            {
                Console.WriteLine("\n\n" + property.Key);
                foreach (string data in (List<string>)property.Value)
                {
                    Console.WriteLine(data + "\t");
                }
            }
            else if (property.Value is Dictionary<string, object>)
            {
                Console.WriteLine("\n\n" + property.Key);
                foreach (KeyValuePair<string, object> data in (Dictionary<string, object>)property.Value)
                {
                    if (property.Value is Dictionary<string, object>)
                    {
                        foreach (KeyValuePair<string, object> data1 in (Dictionary<string, object>)data.Value)
                        {
                            Console.WriteLine(data1.Key + "\t" + data1.Value);
                        }
                    }
                    else
                    {
                        Console.WriteLine(data.Key + "\t" + data.Value);
                    }
                }
            }
            else
            {
                Console.WriteLine(property.Key + "\t" + property.Value);
            }
        }

        //BulkAPIResponse<ZCRMRecord> relatedlist = record.GetRelatedListRecords("Products"); //To get Related records of a record
        ///** Related records is of type ZCRMRecord **/
        //List<ZCRMRecord> lists = relatedlist.BulkData; //To get related list data
        //foreach (ZCRMRecord rec in lists)
        //{
        //    Console.WriteLine(rec.EntityId); //To get  record id
        //    Console.WriteLine(rec.ModuleAPIName); //To get module api name
        //}

        BulkAPIResponse<ZCRMNote> noteResponse = record.GetNotes(); //To get record notes
        //BulkAPIResponse<ZCRMNote> noteResponse = record.GetNotes(1,10); //page, perPage.
        //BulkAPIResponse<ZCRMNote> noteResponse = record.GetNotes("title", CommonUtil.SortOrder.asc); //sortByField, sortOrder
        //BulkAPIResponse<ZCRMNote> noteResponse = record.GetNotes("title", CommonUtil.SortOrder.asc,1,10, "2019-12-25T04:00:00+02:00"); //sortByField, sortOrder, page, perPage and modifiedSince(Header)
        List<ZCRMNote> notes = noteResponse.BulkData;
        foreach (ZCRMNote note in notes)
        {
            Console.WriteLine(note.Id); //To get note id
            Console.WriteLine(note.Title); //To get note title
            Console.WriteLine(note.Content); //To get note content

            ZCRMRecord parentRecord = note.ParentRecord; //To get note's parent record
            Console.WriteLine(parentRecord.EntityId); //To get note's parent record id
            Console.WriteLine(parentRecord.ModuleAPIName); // To get note's parent record Module API name

            ZCRMUser noteCreatedBy = note.CreatedBy;
            Console.WriteLine(noteCreatedBy.Id); //To get UserId who created the notes
            Console.WriteLine(noteCreatedBy.FullName); //To get User name who created the notes

            ZCRMUser noteModifiedBy = note.ModifiedBy;
            Console.WriteLine(noteModifiedBy.Id); //To get UserId who modified the notes
            Console.WriteLine(noteModifiedBy.FullName); //To get User name who modified the notes

            ZCRMUser noteOwner = note.NotesOwner;
            Console.WriteLine(noteOwner.Id); //To get notes OwnerId
            Console.WriteLine(noteOwner.FullName); //To get notes Owner name

            Console.WriteLine(note.CreatedTime); //To get created time of the note
            Console.WriteLine(note.ModifiedTime); //To get modified time of the note

            List<ZCRMAttachment> noteAttachment = note.Attachments; //To get attachments of the note record
            if (noteAttachment != null) //check If attachments is empty/not
            {
                foreach (ZCRMAttachment attachment in noteAttachment)
                {
                    Console.WriteLine(attachment.Id); //To get the note's attachment id
                    Console.WriteLine(attachment.FileName); //To get the note's attachment file name
                    Console.WriteLine(attachment.FileType); //To get the note's attachment file type
                    Console.WriteLine(attachment.Size); //To get the note's attachment file size

                    ZCRMRecord attachmentRecord = attachment.ParentRecord;
                    Console.WriteLine(attachmentRecord.EntityId); //To get the note's parent record id
                    Console.WriteLine(attachmentRecord.ModuleAPIName); //To get the record name

                    ZCRMUser noteAttachmentCreatedBy = note.CreatedBy;
                    Console.WriteLine(noteAttachmentCreatedBy.Id); // To get user_id who created the note's attachment
                    Console.WriteLine(noteAttachmentCreatedBy.FullName); //To get user name who created the note's attachment

                    ZCRMUser noteAttachmentModifiedBy = note.ModifiedBy;
                    Console.WriteLine(noteAttachmentModifiedBy.Id); //To get user_id who modified the note's attachment
                    Console.WriteLine(noteAttachmentModifiedBy.FullName); //To get user name who modified the note's attachment

                    ZCRMUser noteAttachmentOwner = note.NotesOwner;
                    Console.WriteLine(noteAttachmentOwner.Id); //To get the note's attachment owner id
                    Console.WriteLine(noteAttachmentOwner.FullName); //To get the note's attachment owner name

                    Console.WriteLine(attachment.CreatedTime); //To get attachment created time
                    Console.WriteLine(attachment.ModifiedTime); //To get attachment modified time

                }
            }
        }

        BulkAPIResponse<ZCRMAttachment> attachmentResponse = record.GetAttachments(); //To get record's attachments 
        //BulkAPIResponse<ZCRMAttachment> attachmentResponse = record.GetAttachments(0,10, "019-12-25T04:00:00+02:00"); //page, perPage and modifiedSince(Header)
        List<ZCRMAttachment> attachments = attachmentResponse.BulkData; // To get list of attachments
        foreach (ZCRMAttachment attachment in attachments)
        {
            Console.WriteLine(attachment.Id); //To get the attachment id
            Console.WriteLine(attachment.FileName); //To get attachment file name
            Console.WriteLine(attachment.FileType); // To get attachment file type
            Console.WriteLine(attachment.Size); //To get attachment file size

            ZCRMRecord attachmentRecord = attachment.ParentRecord;
            Console.WriteLine(attachmentRecord.EntityId); //To get the parent record id
            Console.WriteLine(attachmentRecord.ModuleAPIName); //To get the parent record name

            ZCRMUser attachmentCreatedBy = attachment.CreatedBy;
            Console.WriteLine(attachmentCreatedBy.Id); // To get user_id who created the  attachment
            Console.WriteLine(attachmentCreatedBy.FullName); //To get user name who created the  attachment

            ZCRMUser attachmentModifiedBy = attachment.ModifiedBy;
            Console.WriteLine(attachmentModifiedBy.Id); //To get user_id who modified the attachment
            Console.WriteLine(attachmentModifiedBy.FullName); //To get user name who modified the attachment

            ZCRMUser noteAttachmentOwner = attachment.Owner;
            Console.WriteLine(noteAttachmentOwner.Id); //To get the attachment owner id
            Console.WriteLine(noteAttachmentOwner.FullName); //To get the attachment owner name

            Console.WriteLine(attachment.CreatedTime); //To get attachment created time
            Console.WriteLine(attachment.ModifiedTime); //To get attachment modified time

            FileAPIResponse fResponse = attachment.DownloadFile(); //To download the attachment file
            Console.WriteLine("File Name:" + fResponse.GetFileName()); // To get attachment file name
            Console.WriteLine("HTTP Status Code:" + fResponse.HttpStatusCode); //To get HTTP status code 
            Stream file = fResponse.GetFileAsStream(); //To get attachment file content
            CommonUtil.SaveStreamAsFile("/Users/pboyle-73/Desktop/photo", file, fResponse.GetFileName()); //To write a new file using the same attachment name
        }


        ZCRMLayout layout = record.Layout; //To get record layout
        if (layout != null)
        {
            Console.WriteLine(layout.Id); //To get layout_id
            Console.WriteLine(layout.Name); //To get layout name 
        }

        /** Following methods are being used only by Inventory modules */
        List<ZCRMTax> taxlists = record.TaxList; //To get the tax list
        foreach (ZCRMTax tax in taxlists)
        {
            Console.WriteLine(tax.TaxName); //To get tax name
            Console.WriteLine(tax.Percentage); //To get tax percentage
            Console.WriteLine(tax.Value); //To get tax value
        }

        List<ZCRMInventoryLineItem> lineItems = record.LineItems; //To get list of line_items
        foreach (ZCRMInventoryLineItem lineItem in lineItems)
        {
            Console.WriteLine(lineItem.Id); //To get lineItem id
            Console.WriteLine(lineItem.ListPrice); //To get lineItem list price
            Console.WriteLine(lineItem.Quantity); //To get lineItem quantity
            Console.WriteLine(lineItem.Description); //To get lineItem description
            Console.WriteLine(lineItem.Total); //To get lineItem total amount
            Console.WriteLine(lineItem.Discount); //To get lineItem discount
            Console.WriteLine(lineItem.DiscountPercentage); //To get lineItem discount percentage
            Console.WriteLine(lineItem.TotalAfterDiscount); //To get lineItem amount after discount
            Console.WriteLine(lineItem.TaxAmount); //To get lineItem tax amount
            Console.WriteLine(lineItem.NetTotal); //To get lineItem net total amount
            Console.WriteLine(lineItem.UnitPrice); //To get lineItem unit price
            Console.WriteLine(lineItem.Product.EntityId); //To get line_item product's entity id
            Console.WriteLine(lineItem.Product.LookupLabel); //To get line_item product's lookup label

            List<ZCRMTax> linetaxs = lineItem.LineTax; //To get list of line_tax in lineItem
            foreach (ZCRMTax tax in linetaxs)
            {
                Console.WriteLine(tax.TaxName); //To get line tax name
                Console.WriteLine(tax.Percentage); //To get line tax percentage
                Console.WriteLine(tax.Value); //To get line tax value
            }
        }

        List<ZCRMPriceBookPricing> pricedetails = record.PriceDetails; //To get the price details array
        foreach (ZCRMPriceBookPricing pricedetail in pricedetails)
        {
            Console.WriteLine(pricedetail.Id); //To get the record's priceId
            Console.WriteLine(pricedetail.ToRange); //To get the price detail record's to_range
            Console.WriteLine(pricedetail.FromRange); //To get the price detail record's from_range
            Console.WriteLine(pricedetail.Discount); //To get the price detail record's discount
        }
        /**  End Inventory **/

        /** Following method is used only by 'Events' module */
        List<ZCRMEventParticipant> participants = record.Participants; //To get Event record's participants
        foreach (ZCRMEventParticipant participant in participants)
        {
            Console.WriteLine(participant.Id); //To get the record's participant id
            Console.WriteLine(participant.Name); //To get the record's participant name
            Console.WriteLine(participant.Email);//To get the record's participant email
            Console.WriteLine(participant.Type); //To get the record's participant type
            Console.WriteLine(participant.IsInvited); //To check if the record's participant(s) are invited or not
            Console.WriteLine(participant.Status); //To get the record's participants' status
        }
         End Event */
    }

}
 
レコードのタグ
レコードへのタグの追加

/** Add Tags to a Specific record */
public void AddTagSpecificRecord()
{
    ZCRMRecord tag = ZCRMRecord.GetInstance("Leads", 538518000449026); ///Module API Name, record id
    List<string> tagname = new List<string>() { "N1","N2"};
    APIResponse response = tag.AddTags(tagname); //tagNames is List

    ZCRMRecord tags = (ZCRMRecord)response.Data;
    Console.WriteLine(tags.ModuleAPIName);
    Console.WriteLine(tags.EntityId);
    foreach (string tagnames in tags.TagNames)
    {
        Console.WriteLine(tagnames);
    }
    Console.WriteLine(response.Message);
    Console.WriteLine(response.Status);
    Console.WriteLine(response.HttpStatusCode);
    Console.WriteLine(response.ResponseJSON);
}
 
レコードからのタグの削除

/** Remove Tags from a Specific record */
public void RemoveTagSpecificRecord()
{
    ZCRMRecord tag = ZCRMRecord.GetInstance("Leads", 538518000449064); //Module API Name, record id
    List<string> tagname = new List<string>() { "N1", "N2" };
    APIResponse response = tag.RemoveTags(tagname);
    ZCRMRecord tags = (ZCRMRecord)response.Data;
    Console.WriteLine(tags.ModuleAPIName);
    Console.WriteLine(tags.EntityId);
    foreach (string tagnames in tags.TagNames)
    {
        Console.WriteLine(tagnames);
    }
    Console.WriteLine(response.Message);
    Console.WriteLine(response.Status);
    Console.WriteLine(response.HttpStatusCode);
    Console.WriteLine(response.ResponseJSON);
}