If Else statement runs sometimes, i don't know what is the problem. The same script is launched two times, at the first time it runs, at the second one, no. Is ther a poltergeist in Alfresco? I think it's a big bug.
I think that i found my error: sometimes the object is use was a space and sometimes a document, so that was the problem. I thought that i will become crazy.