Hi,
I am guessing your issues is that your presume myAssets is an array like. Infact, it's a String made of the first occurence of FileName.
When you loop through myAssets length, you are actually working with every single character of the string. If myAssets is "a.pdf", you will process "a", then"." then "p" then "d" then "f".
Here is my proposal, rather than looking into the metadata and given that the xml file is the job, I suggest to load a document and look through nodes :
Code: Select all
// Is invoked each time a new job arrives in one of the input folders for the flow element.
// The newly arrived job is passed as the second parameter.
function jobArrived( s : Switch, job : Job )
{
var d = new Document ( job.getPath() );
var f, url, j, displaced = 0;
var elems = d.evalToNodes("/Order/Assets/FileName");
var n = elems.getCount( );
while (n--) {
url = "/Users/ozalto/Desktop/"+elems.getItem(n).evalToString(".");
if ( File.exists ( url ) ) {
s.log(-1,"File found" );
f = new File ( url );
j = s.createNewJob(url);
j.sendToSingle(url);
displaced++;
}
else {
s.log(3, "File not found "+url );
}
}
if ( displaced == n ) job.sendToNull();
else job.fail();
}
HTH,
Loic
http://www.ozalto.com