Page 1 of 1

Outgoing Connection path in javascript.

Posted: Tue Nov 26, 2013 6:43 pm
by sgeller


Is there a way to get the path for an outgoing connection?



I've been able to use s.getOutConnections().getItem(0).getFolderName() to get the name of the folder, but can't seem to find a way to get a full path for the folder.

Outgoing Connection path in javascript.

Posted: Tue Nov 26, 2013 8:59 pm
by dkelly
Both Connection and Occurrence classes only provide the folder name as displayed on the canvas. Not the directory path.

Outgoing Connection path in javascript.

Posted: Wed Nov 27, 2013 4:36 pm
by dkelly
Hack warning!



var myFlowName = s.getFlowName();

var myElementName = s.getElementName();

var outgoingConnectionID = s.getOutConnections().getItem(0).getElementID();



var switchFlowsDir = "/Users/dkelly/Library/Application Support/Enfocus/Switch Server/flows";



var pathDir = "";



var flowDir = new Dir(switchFlowsDir);

var flowEntries = flowDir.entryList("*.xml", Dir.Files, Dir.Name);

for (var i=0; i<flowEntries.length; i++) {

var xmlDoc = new Document(switchFlowsDir + "/" + flowEntries);

// find the flow

var flowName = xmlDoc.evalToString("//Header/Fields/Name");

if (flowName == myFlowName) {

// find the connection

var connectionNode = xmlDoc.evalToNode("//Object[@Class="connection" and @Id=""+outgoingConnectionID+]");

var outgoingFolderID = connectionNode.evalToString("./Fields/Destobject");

// find the folder element

var folderNode = xmlDoc.evalToNode("//Object[@Class="object" and @Id=""+outgoingFolderID+]");

pathDir = folderNode.evalToString("./Fields/Path");

break;

}

delete xmlDoc;

}

delete flowDir;



if (pathDir.length)

s.log(1, "output folder: " + pathDir);

else

s.log(3, "Could not locate output folder for flow " + myFlowName + " and connection " + outgoingConnectionID);