cancel
Showing results for 
Search instead for 
Did you mean: 

Compare Nodes within a Java-Script

d_franz
Champ on-the-rise
Champ on-the-rise
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.


1 REPLY 1

scouil
Star Contributor
Star Contributor
Hello,

I see nothing wrong with that script.
How do you check wether the comparison fails or not? Only by checking that the aspect has been applied to the parent?
If so I'd suggest you to try to debug your script step by step in the javascript debugger.

Regards,