AnsweredAssumed Answered

JavaScript commands ignore if wrongly placed

Question asked by simon on Sep 4, 2006
Latest reply on Sep 5, 2006 by simon
Hi,

I ran into a small bug (if I'm not mistaken) in the JavaScript API. I tried to change the name of my copied document but if you place the copy.name command above the if statement the copied document keeps the original name. If you place it right before the copy.safe command everything works. Can anyone confirm this?

Works fine:
if ( !copy.hasAspect("cm:generalclassifiable") ) {
   copy.addAspect("cm:generalclassifiable");
}
copy.name = "someNewName";
copy.save();

Does NOT work:
copy.name = "someNewName";
if ( !copy.hasAspect("cm:generalclassifiable") ) {
   copy.addAspect("cm:generalclassifiable");
}
copy.save();

Outcomes