AnsweredAssumed Answered

Compare Nodes within a Java-Script

Question asked by d_franz on Jul 10, 2013
Latest reply on Jul 11, 2013 by scouil
I have a script that starts after a file with a specific aspect has been deleted. A function of this script is searching in the folder of the file for other files with the same aspect. Is there no other file it sets an aspect to the folder.

Is there a way to compare two nodes? In the following script I also get an unequal for nodes that are the same (the deleted node).


function checkSpaceForAspect(node, asp, aspToSet)
{
   i = 0;
   var nodeSpace = node.parent;
   
   for each (n in nodeSpace.children)
   {
      if(n.hasAspect(asp))
      {
         if(node.nodeRef!= n.nodeRef)
         {
            return;
         }
      }
   }
   //No Aspect found
   addAspToParent(node, aspToSet, "0");   
   return;
}


The only solution that works in the moment is to count the files that have the same aspect as the deleted file. If it is 1, there is no other file.


Outcomes