cancel
Showing results for 
Search instead for 
Did you mean: 

If Else Statement in Javascript does not run

raquelcasaus
Champ in-the-making
Champ in-the-making
Hi, all,

I have a problem: I'm trying to use if else statement into a script, but alfresco execute both options:

if (UserSpace== null)
{
var One = AnotherSpace.createFile("One.html");
}

else
{
var Two = UserSpace.createFile("Two.html");   
}

The result is that "One.html" and "Two.html" file are created. Why?

Thank you in advance. Raquel.
4 REPLIES 4

raquelcasaus
Champ in-the-making
Champ in-the-making
Hi, again,

It seems that now it's running, i don't know why. I only rewrite the code with another variable names,… but the structure is the same.

Thank you. Raquel.

raquelcasaus
Champ in-the-making
Champ in-the-making
Hi, again,

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.

Regards. Raquel.

davidc
Star Contributor
Star Contributor
I would be very surprised if there was an issue with if/else in javascript.

One thing you can try is to use undefined instead of null (but be careful which equality operator you use).

See http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Properties:undefined

raquelcasaus
Champ in-the-making
Champ in-the-making
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.

Thank you a lot. Raquel.