Answered

Get file from Array

Hello!

I try get file from array of entities.

RequestToServiceDesk - entity

Files - file attribute

Emails - entity

Attachments - file attribute

RequestToServiceDesk have collection of Emails.

I do it:

var OriginalFile = Me.getXPath("RequestToServiceDesk.Files");

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

{

//Obtain the file data

var FiletoCopy = OriginalFile.get(i);

var Name = FiletoCopy.getXPath("FileName");

var Data = FiletoCopy.getXPath("Data");

}

It's work.

Then I try:

var filter = "NewEmail="+true + " AND RequestToServiceDesk=" + <RequestToServiceDesk.Id>;

var list = CEntityManager.GetEntity("Emails").GetEntityList("", "", filter, "");

var OriginalFile = list[0].Attributes["Attachments"].Value;

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

{

//Obtain the file data

var FiletoCopy = OriginalFile.get(i);

var Name = FiletoCopy.getXPath("FileName");

var Data = FiletoCopy.getXPath("Data");

}

It's not work.

What I can do about this? Please help!

photo
0

Dear Sofya,

Here is an example of a rule to loop a entity of files and add each file into a collection of files:

Int i=0;

Object EntArchivosList=null;

EntFilesList= CEntityManager.GetEntity("ParametricEntityfiles").GetEntityList("", "", "", "");

for(i=0; i< EntFilesList.Length; i++)

{

var key=EntFilesList.SurrogateKeyValue;

var newFile= Me.addRelation("CreditRequest.files");

newFile.setXPath('ParametricEntityfiles',key);

}

Help: http://wiki.bizagi.com/en/index.php?title=Other_Rules

Regards

photo
0

thank you