I am currently developing webscripts using alfresco 4.2.d and javascript, and have found one strange behaviour: On all of my webscript, the removeAssociation function removes the association on the relevant node as well as the sourceAssocs reference on the source node. However in one of my webscript it doesn't remove the sourceAssocs reference. The weird thing is, I use the exact same code, with the same input in another of my webscript, and there it works.
Here is the model : <blockcode> <type name="delegation:content"> <title>Porte l'ensemble des délégations que porte une personne</title> <parent>cm:content</parent> <properties> <property name="delegation:username"> <type>d:text</type> </property> </properties> <associations> <association name="delegation:delegataire"> <title>Personne délégataire</title> <description>Association vers la personne qui délègue ses contact</description> <source> <mandatory>false</mandatory> <many>true</many> </source> <target> <class>cmerson</class> <mandatory>true</mandatory> <many>false</many> </target> </association> <association name="delegation:delegue"> <title>Personne déléguée</title> <description>Association vers le personnes à qui on délègue les contacts</description> <source> <mandatory>false</mandatory> <many>true</many> </source> <target> <class>cmerson</class> <mandatory>false</mandatory> <many>true</many> </target> </association> </associations> <type> </blockcode>
The transaction is set on "required" in the descriptor of both of my webscripts.
Here is the code: <javascript> /* I retrieve the "delegation" nodes linked by "delegation:delegue" to my user Then I remove the association */ var delegationNodes = user.sourceAssocs["delegation:delegue"]; for (var i = 0 ; i < delegableNodes.length ; i++){ var delegationNode = delegationNodes; delegationNode.removeAssociation(user, "delegation:delegue"); } </javascript>