cancel
Showing results for 
Search instead for 
Did you mean: 

bi direction association

etoropov
Champ in-the-making
Champ in-the-making
Is it possible to implement in Alfresco that would add to the content in the linked document newly created document is attached to the bound?
Ex.:
There is DocA. Create DocB (another type)
and add DocA as linked document to this DocB. How to do that new DocB would be automatically added to DocA?
Came up with the only option with javascript, which is hung as rule on the folder. while saviong or changing the document is searched for the attachment of the document and add the document as an association. Question - how to get to the name of the attached document (cm:name of attached document DocA(DocA_name))?

var insp = "@cm\\:name:DocA_name"; // it's hardcode. how to get DocA_name?

results = search.luceneSearch(insp);

for (var i = 0; i<results.length; i++){
    results[i].createAssociation(document, "sc:DocA4DocB" );
}
document.save();

model:
<type name="sc:DocA">
   <title>DocA</title>
   <parent>sc:document</parent>
   <properties>
          …
   </properties>
   <associations>
      <association name="sc:DocA4DocB">
         <title>DocA4DocB</title>
         <source>
            <mandatory>false</mandatory>
            <many>true</many>
         </source>
         <target>
            <class>cm:content</class>
            <mandatory>false</mandatory>
            <many>true</many>
         </target>
      </association>
   </associations>
</type>
<type name="sc:DocB">
   <title>DocB</title>
   <parent>sc:document</parent>
   <properties>
          …
   </properties>
   <associations>
      <association name="sc:DocB4DocA">
         <title>DocB4DocA</title>
         <source>
            <mandatory>false</mandatory>
            <many>true</many>
         </source>
         <target>
            <class>sc:DocA</class>
            <mandatory>false</mandatory>
            <many>true</many>
         </target>
      </association>
   </associations>
</type>
3 REPLIES 3

amandaluniz_z
Champ on-the-rise
Champ on-the-rise
You could do it using behaviours so you don't have to set rules manually

etoropov
Champ in-the-making
Champ in-the-making
You could do it using behaviours so you don't have to set rules manually
Hi,
Which behaviours do you mean?

amandaluniz_z
Champ on-the-rise
Champ on-the-rise
Oh, you would have to write your own policy implementing the OnUpdateNodePolicy and checking that what's being updated is the association
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.