I'm looking for a solution to check for a file in a specific folder, the file has a prefix PRD_ which is always the same but the filename itself changes with every job.
Currently I check only if the folder exist, if not a sync process starts but sometimes the PRD_ file is missing. I have to make sure that the PRD_xxx file inside that folder exists before the workflow continues.
The current script is this:
Code: Select all
function findConnectionByName( s : Switch, inName : String ) : Connection
{
var outConnectionList = s.getOutConnections();
for (i=0; i < outConnectionList.length; i++) {
var theConnection = outConnectionList.getItem(i);
var theName = theConnection.getName();
if (inName == theName)
return theConnection;
}
return null;
}
function jobArrived( s : Switch, job : Job )
{
var JobTicketID = job.getVariableAsString('[Metadata.Text:Path="/STÜCKLISTE/KOPF/CONFID",Dataset="meineKonfigID",Model="XML"]');
var TicketPathVIP = "//cs-switch/Bilddaten-VIP/"+JobTicketID;
var theConnectionName = "BASISDATENHOLEN";
if (File.exists(TicketPathVIP)) {
theConnectionName = "BASISDATENOK";
}
if (theConnectionName.length) {
var theConnection = findConnectionByName(s, theConnectionName);
if (theConnection != null) {
job.sendTo( theConnection, job.getPath() );
} else {
job.fail( "Unable to find connection named '"+theConnectionName+"'");
}
}
}
function timerFired( s : Switch )
{
}
var TicketPathVIP = "//cs-switch/Bilddaten-VIP/"+JobTicketID+"/PRD_*";
thanks for any hint,
Daniel