Outgoing Connection path in javascript.

Post Reply
sgeller
Newbie
Posts: 7
Joined: Wed Jan 18, 2012 1:53 am

Outgoing Connection path in javascript.

Post 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.
dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Outgoing Connection path in javascript.

Post by dkelly »

Both Connection and Occurrence classes only provide the folder name as displayed on the canvas. Not the directory path.
dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Outgoing Connection path in javascript.

Post 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);

Post Reply