Assuming this is repo tier Javascript, you are really dealing with Java NodeRef
objects and ==
behaves like it does in Java and compares identity. You want to compare equivalence, so use personRef.equals(userAssocNodeRef)
. Yes, pretty unexpected behavior. Beware of Strings and Date objects as well.
How to compare two noderefs in alfresco javascript
-
19-07-2023 - |
Pergunta
I am have two noderefs in alfresco javascript file which i am trying to compare as below.
if(personRef == userAsscNodeRef){
do something
}else{
do something else
}
It seems to be syntactically correct but always going to else part. I tried with strict equal i.e. === as well as adding .toString() to both noderefs but still same result.
How can it be possible?
Regards.
Solução
Outras dicas
Use String()
:
if(String(personRef) == String(userAsscNodeRef)){
do something
}else{
do something else
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow