C# SDK Samples - Note Client Operations
Notes
Upload a Note Attachment
/** Upload a note attachment */
public void NoteAttachment()
{
ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 538518000000449026); //module api name with record id
ZCRMNote note = ZCRMNote.GetInstance(recordIns, 538518000000450116); //record instance with note id
APIResponse aResponse = note.UploadAttachment("/Users/Desktop/test.html");
ZCRMAttachment attachment = (ZCRMAttachment)aResponse.Data;
Console.WriteLine(attachment.Id); //To get the note's attachment id
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 = attachment.CreatedBy;
if(noteAttachmentCreatedBy!=null)
{
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 = attachment.ModifiedBy;
if(noteAttachmentModifiedBy!= null)
{
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 = attachment.Owner;
if(noteAttachmentOwner!=null)
{
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
}
Download a Note Attachment
/** Download a note attachment */
public void DownloadAttachment()
{
ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 538518000000449026); //module api name with record id
ZCRMNote note = ZCRMNote.GetInstance(recordIns, 538518000000450116); //record instance with note id
FileAPIResponse aResponse = note.DownloadAttachment(538518000000464022);
Stream file = aResponse.GetFileAsStream();
CommonUtil.SaveStreamAsFile("/Users/Desktop/photo", file, aResponse.GetFileName());
Console.WriteLine(aResponse.Message);
Console.WriteLine(aResponse.Status);
}
Delete a Note Attachment
/** Delete a note attachment */
public void DeleteAttachment()
{
ZCRMRecord recordIns = ZCRMRecord.GetInstance("Leads", 538518000000449026); //module api name with record id
ZCRMNote note = ZCRMNote.GetInstance(recordIns, 538518000000450116); //record instance with note id
APIResponse aResponse = note.DeleteAttachment(538518000000464022);
Console.WriteLine(aResponse.Message);
Console.WriteLine(aResponse.Status);
}
Tags
Update a Tag
/** Single Tag update */
public void UpdateTag()
{
ZCRMTag tagIns = ZCRMTag.GetInstance(538518000000449048, "Leads");//3372164000001597013 tag id ,Module Api Name
tagIns.Name = "updateName1";
APIResponse response = tagIns.Update();
ZCRMTag tag = (ZCRMTag)response.Data;
Console.WriteLine(tag.Id);
Console.WriteLine(tag.Name);
ZCRMUser createdBy = tag.CreatedBy;
Console.WriteLine(createdBy.Id);
Console.WriteLine(createdBy.FullName);
ZCRMUser modifiedBy = tag.ModifiedBy;
Console.WriteLine(modifiedBy.Id);
Console.WriteLine(modifiedBy.FullName);
Console.WriteLine(tag.CreatedTime);
Console.WriteLine(tag.ModifiedTime);
Console.WriteLine(response.Message);
Console.WriteLine(response.Status);
Console.WriteLine(response.ResponseJSON);
}
Delete a Tag
/** Single Tag delete */
public void DeleteTag()
{
ZCRMTag tagdelete = ZCRMModule.GetTagInstance(538518000000449049);
APIResponse deleteTag = tagdelete.Delete();
Console.WriteLine(deleteTag.Data);
Console.WriteLine(deleteTag.Message);
Console.WriteLine(deleteTag.Status);
Console.WriteLine(deleteTag.HttpStatusCode);
Console.WriteLine(deleteTag.ResponseJSON);
}
Merge Tags
/** Single Tag merge */
public void MergeTag()
{
ZCRMTag tag = ZCRMModule.GetTagInstance(538518000000445037); //tag id
ZCRMTag tagmerge = ZCRMModule.GetTagInstance(538518000000449048); //conflict tag id
APIResponse mergeTag = tag.Merge(tagmerge);
ZCRMTag merge = (ZCRMTag)mergeTag.Data;
Console.WriteLine(merge.Id);
ZCRMUser createdBy = merge.CreatedBy;
Console.WriteLine(createdBy.Id);
Console.WriteLine(createdBy.FullName);
ZCRMUser modifiedBy = merge.ModifiedBy;
Console.WriteLine(modifiedBy.Id);
Console.WriteLine(modifiedBy.FullName);
Console.WriteLine(merge.CreatedTime);
Console.WriteLine(merge.ModifiedTime);
Console.WriteLine(mergeTag.Message);
Console.WriteLine(mergeTag.Status);
Console.WriteLine(mergeTag.HttpStatusCode);
Console.WriteLine(mergeTag.ResponseJSON);
}