cancel
Showing results for 
Search instead for 
Did you mean: 

removeAssociation and sourceAssocs

fixit
Champ in-the-making
Champ in-the-making
Hi,

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>cmSmiley Tongueerson</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>cmSmiley Tongueerson</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>

Is there any explanation to this problem ?
1 REPLY 1

fixit
Champ in-the-making
Champ in-the-making
If that can help, in my "trouble case" the sourceAssocs is removed indeed, but only after the webscript execution.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.