cancel
Showing results for 
Search instead for 
Did you mean: 

Association mandatory problem

theterz
Champ in-the-making
Champ in-the-making
Hi all,
I have a problem with a mandatory association.

I have create a model with an aspect that has more properties and an association (target cmSmiley Tongueerson).
With a rule definded on a folder I apply aspect to all documents uploaded to the folder.
I'd like this association was mandatory but If I defined it as

                <association name="custom:field1">
                    <source>
                        <mandatory>true</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>cm:person</class>
                        <mandatory>true</mandatory>
                        <many>false</many>
                    </target>
                </association>

user get error when try to upload a file:
Operazione non riuscita: Found integrity violations:
The association target multiplicity has been violated:
   Source Node: workspace://SpacesStore/e0ff6142-cedb-493f-9171-ee64743fedcf
   Association: Association[ class=ClassDef[name={custom}corrIn], name={custom}CorrInDest, target class={http://www.alfresco.org/model/content/1.0}person, source role=null, target role=null]
   Required target Multiplicity: 1..1
   Actual target Multiplicity: 0

Instead, if I defined my aspect as

                <association name="custom:field1">
                    <source>
                        <mandatory>true</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>cm:person</class>
                        <mandatory>false</mandatory>
                        <many>false</many>
                    </target>
                </association>

user can upload document but when he edits properties field may be empty.
Do you have any suggestions
1 REPLY 1

mitpatoliya
Star Collaborator
Star Collaborator
that is because your rule gets executed after document is created in alfresco.
But at the time of creation alfresco is validating integrity of node with model and because this issue occurs.
Also what you can try rather then using out of box apply aspect rule crate a script which will do association and then apply that aspect on current node and create a rule which will invoke that script on document creation.
This approach may solve your problem.