Skip to main content

Add an attachment from a form to a related documents object

With the Associated Documents object, to the document selected through document management. In order to add the files we added to the attachment object on the form, we examine the following code block in detail and click You can revise it according to your system

'''%SystemPath%\Common\eBAPI.dll using System; using System.Collections; using System.Text; using System.Data; using eBAControls; using eBAControls.eBABaseForm; using eBAFormData; using eBAPI; using eBAPI.Connection; using eBAPI.DocumentManagement; using System.IO;

namespace RelationsAttachment {

public partial class Form {

public void RelatedDocuments1_OnAfterRelation(object sender, eBARelationFileEventArgs e) { Text1.Text=e.Filename; The path information of the related documents object is accessed }

public void Ekekle_OnClick(Object sender, EventArgs e) { eBAConnection con = CreateServerConnection();
Try { Con. open(); string fileNameRel=Text1.Text;//The path of the Related Documents object is passed DMFile form = con. FileSystem.GetFile(Filename); foreach (var item in form. GetAttachments("default")) //We are navigating through the attachment in the form { byte[] arr =con. FileSystem.DownloadFileAttachmentContentToByteArray(form. Path,"default",item. ContentName);
DMFile relFilename = con. FileSystem.GetFile(fileNameRel); Con. FileSystem.UploadFileAttachmentContentFromByteArray(relFilename.Path,"default",item. ContentName,arr); We attach the files we find in the Attachtext to the attachments of the related documents } } finally { Con. Close(); } }

} }