Copy file type fields from one table to another table

I am trying to read all records of an employee table in order to copy existing fields of file type to another table.

In my context, I have ConversionOfDocuments (process table)

which has a collection attribute xEmployee associated to the table M_Employee

which in turn has a collection attribute xDocuments associated to the table M_Documents

var xEmployeeList = Me.getXPath("entity-list('M_Employee','"+sFilter+"')");

for (var i=0; i < xEmployeeList.size(); i++)


CHelper.trace("DocConversion","Employee first name= " + xEmployeeList[i].getXPath("sEmplFirstName") + " and employee last name = " + xEmployeeList[i].getXPath("sEmployeeName"));

// this line gives me an error as bizabi does not allow to do a new collectionotem like that.

xNewDocument = xEmployeeList[i].newCollectionItem("ConversionOfDocuments.xEmployee.xDocuments");

sDocName = "documentname";

dUploadedDate = DateTime.Now;

iUploadedBy = 1; // user = admon

iMandateHistory = null;







CHelper.trace("DocConversion","avamt section document");

// document type 1 - Annexe 3

xOriginalFile = Me.getXPath("M_Employee.uEmplAnnexe3");

if (xOriginalFile != null)


for (var i=0; i < xOriginalFile.size(); i++)


FileToCopy = xOriginalFile.get(i);

sFileName = FileToCopy.getXPath("FileName");

sFileData = FileToCopy.getXPath("Data");

NewFile = Me.addRelation("M_Documents.uDocFile");

NewFile.setXPath("FileName", sFileName);

NewFile.setXPath("Data", sFileData);




iConvertedRecords = iConvertedRecords + 1;


Please help?

Comments (1)


Dear Daniel

We have very little information on your data model and use case, therefore it's hard to understand what you are trying to accomplish.

We understand, you are trying to create a new item in a collection. Have you tried get(i) ?


Also, you may not need the absolute XPath to get to xDocuments since you are not using Me.newCollectionItem(). The employee is already in the context when you call xEmployeeList.get(i).newCollectionItem(""). You may only need "xDocuments" as a paratemeter.

Please let us know if this helps.

Best Regards