Dear community, I ask for your help in finding an error in my code. I can't find it myself :(
Task: go from the lower position in the organizational structure to upper division and get all the divisions, including the upper one.
My code seems logical to me, but when running it loops on one of the nodes, for example, on the Depute object (if you run it from the Engineer 1.1 object.).
I ask the respected community for help in solving the problem.
My code:
var gl = Context.getSelectedLanguage(); var startObjectOccs = ArisData.getSelectedObjOccs(); var myArr = []; for (var i=0;i<startObjectOccs.length;i++){ findUnits(startObjectOccs[i]); }for (var j=0;j<myArr.length;j++){ Dialogs.MsgBox("Found divisions: " + myArr[i]); } function findUnits(occ){ var currCnxArr = occ.Cxns(Constants.EDGES_INOUT); Dialogs.MsgBox("Check (length of the links array): " + currCnxArr.length); //var unitArr = []; for (i=0; i<currCnxArr.length;i++){ if (currCnxArr[i].getSource().ObjDef().TypeNum() == 45){ //if the source of connection is a position Dialogs.MsgBox("Check: Next node-position " +currCnxArr[i].getSource().ObjDef().Name(gl)); findUnits(currCnxArr[i].getSource()); } else if (currCnxArr[i].getSource().ObjDef().TypeNum() == 43 && currCnxArr[i].getDefinition().TypeNum() == 7){ //if the source of connection is a division Dialogs.MsgBox("Check: Next node-division " + currCnxArr[i].getSource().ObjDef().Name(gl)); //currCnxArr[j].getDefinition().TypeNum() == 9 myArr.push(currCnxArr[i].getSource().ObjDef().Name(gl)); findUnits(currCnxArr[i].getSource()); } } return; }
Forum:
Choose content type:
Ask a question