Page 1 of 1

Testing to see if a folder exists in a location

Posted: Wed Mar 12, 2014 7:12 pm
by PaulHough
I have a flow that will reach out and grab a folder from a location and injects it into a flow via metadata.



What i need is;



if (folder exists){current code}

else {send email}.



I have tried the job.getFileCount() but I couldn't retrieve a value with a location path.



Any suggestions would be helpful.



Thanks,

PH







function jobArrived( s : Switch, job : Job )

{

var JobNumber = job.getVariableAsString('[Metadata.Text:Path="/field-list/field[2]/field-list/field/value",Dataset="Submit",Model="XML"]');

var theSourcePath = job.createPathWithName( JobNumber );





s.copy( "/Users/prinergy/Desktop/Fake jobs/"+JobNumber, theSourcePath );

job.sendToSingle( theSourcePath );

job.sendToNull( job.getPath() );



s.log(1,JobNumber);

}





Testing to see if a folder exists in a location

Posted: Wed Mar 12, 2014 7:53 pm
by dkelly
You can't send an email directly from a script. You will have to set the email variables and send it using an Email Send element in you flow.



function jobArrived( s : Switch, job : Job )

{

var JobNumber = job.getVariableAsString('[Metadata.Text:Path="/field-list/field[2]/field-list/field/value",Dataset="Submit",Model="XML"]');

var theSourcePath = job.createPathWithName( JobNumber );



var folderName = "/Users/prinergy/Desktop/Fake jobs/"+JobNumber;

if (File.exists(folderName)) {

s.copy( folderName, theSourcePath );

job.sendToSingle( theSourcePath );

job.sendToNull( job.getPath() );



s.log(1,JobNumber);

} else {

s.log(1,"Folder " + folderName + " does not exist");

}

}

Testing to see if a folder exists in a location

Posted: Wed Mar 12, 2014 8:28 pm
by PaulHough
Do i have to declare File as a Var?



Thanks,

PH

Testing to see if a folder exists in a location

Posted: Wed Mar 12, 2014 8:42 pm
by dkelly
no, because File.exists() is a static function.

Testing to see if a folder exists in a location

Posted: Wed Mar 12, 2014 8:57 pm
by PaulHough
Is there a site that lists all of the static function?



Thanks,

Paul hough

Testing to see if a folder exists in a location

Posted: Wed Mar 12, 2014 9:12 pm
by dkelly
No, you have to review the Javascript documentation for each class. It will list the static functions.



http://www.enfocus.com/Manuals/UserGuid ... S/home.htm

Testing to see if a folder exists in a location

Posted: Thu Mar 13, 2014 8:54 pm
by PaulHough
Thanks for your help



PH