Hi,Is there any way in Alfresco to copy a list of associations from one document to another??This is my situation: I have a document that has an association in it's model definition with the following code:
<association name="zis:DistributionList">
<title>Distribution List</title>
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm:person</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
This represents a distribution list form which I will later on extract user names and send emails to each one of them.When you edit the properties of this document you can easily select users from the system and ad them to the list. The next thing I want to do is extract them from this list and this document and write them in the same kind of association BUT in another document.This is what I tried to do:
var source = companyhome.childByNamePath("/Qd1");
var destination = companyhome.childByNamePath("/Destination");
var dlist = source.assocs["zis:DistributionList"];
destination.assocs["zis:DistributionList"] = dlist;That didn't work! I also tried:
for (i in dlist)
{
var uid = dlist[i].properties["cm:userName"];
destination.assocs["zis:DistributionList"][i] = people.getPerson(uid);
}That didn't work either!! I also tried:destination.assocs["zis:DistributionList"] = destination.assocs["zis:DistributionList"].concat(dlist);
That didn't work either!!! I also tried:
for (i in dlist)
{
destination.assocs["zis:DistributionList"] = destination.assocs["zis:DistributionList"].concat(dlist[i]);
}
That didn't work either!!!!Then I found out that destination.assocs["zis
istributionList"] is a read-only.So I said ok!! Lets try a different approach. I'll create an aspect that has this type of an association and add it to an ordinary ("content") type of document with the data extracted from my source file as in the previous attempts.
<aspects>
<aspect name="zis:DistributionListAsp">
<title>Distribution</title>
<associations>
<association name="zis:DistributionListAss">
<title>Distribution List</title>
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm:person</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
</aspect>
</aspects>
Added some code in the web-client-config-custom.xml as well:
<config evaluator="aspect-name" condition="zis:DistributionListAsp">
<property-sheet>
<show-association name="zis:DistributionListAss"/>
</property-sheet>
</config>
<config evaluator="string-compare" condition="Action Wizards">
<aspects>
<aspect name="zis:DistributionListAsp" />
</aspects>
</config>
I tried to do so with the following script:
var source = companyhome.childByNamePath("/Qd1");
var destination = companyhome.childByNamePath("/Regular");
var dlist = source.assocs["zis:DistributionList"];
var asocs = new Array(1);
asocs["zis:DistributionListAss"] = dlist;
destination.addAspect("zis:DistributionListAsp", asocs);
destination.save();
That didn't work either!!!!! The document "Regular" had the [zis
istributionListAsp] aspect BUT the aspect had no data within.I also tried:
var source = companyhome.childByNamePath("/Qd1");
var destination = companyhome.childByNamePath("/Regular");
var dlist = source.assocs["zis:DistributionList"];
var asocs = new Array(1);
for(i in dlist)
{
asocs["zis:DistributionListAss"] = dlist[i].nodeRef;
destination.addAspect("zis:DistributionListAsp", asocs);
out.content += "\nAsocs: (" + i + ")" + asocs["zis:DistributionListAss"];
}
destination.save();
That didn't work either!!!!Can anyone help me with this?? How can I fill in the Distribution list from another list???Thanks,Tom