AnsweredAssumed Answered

Remove associations

Question asked by agey on May 12, 2011
Latest reply on Oct 10, 2012 by mirko79
Hi all,

I have defined an association that relates a 'DocsAdmin' type content to 'Invoice' type content:

<type name="inv:DocsAdmin">
         <title>Admin Documents</title>
       <property name="inv:date">
      <property name="inv:type">


                       <aspect name="inv:docsAssocs">
               <association name="inv:relatedInvoices">
                  <title>Facturas relacionadas</title>

I have created a custom dialog to create and remove relationships of this association. Basically, the dialog retrieves all 'inv:relatedInvoices' associations of a document for display to the user and saves new associations that user sets.

This is the code used to save associations:

//associationsIni = list of retrived associations of the document
     for(NodeRef assocFile: this.associations){
           this.getNodeService().createAssociation(this.editableNode.getNodeRef(), assocFile, ASSOC_FRAS);
//associations = list of associations set by user     
      for(NodeRef assocFile: this.associationsIni){
            this.getNodeService().removeAssociation(this.editableNode.getNodeRef(), assocFile, ASSOC_FRAS);

Well, it´s work fine. I have a custom action for each invoice type content to show all documents associated with it. That is, retrieve documents related to the inverse of the following way:

List<AssociationRef> associationRefList=
               this.getNodeService().getSourceAssocs(this.currentNode.getNodeRef(), Constants.ASSOC_INVOICE);

This action shows the associations created. The problem is when the user deletes one of them, the action continues to show the relationship removed. Why is this? The association is defined for the 'DocsAdmin' type. If the user deletes the association of a document of the 'DocsAdmin' type, should not be completely removed? Should we also remove the relationship in the other document of 'Invoice' type?

Thanks a lot in advance