08-01-2011 11:35 AM
//should always show up in log
logger.log("ASSOC CREATED BEHAVIOR");
if (behaviour.args == null) {
logger.log("No argumants have been set.");
} else {
logger.log(behaviour.args[0].name);
var docAssocs = behaviour.args[0].assocs;
//define association type to be used
var refAssocs = ["rmc:crossreference","rmc:supports",
"rmc:versions","rmc:obsoletes",
"rmc:supersedes","rmc:rendition"];
var assocFileNames = [];
for(var type = 0; type < refAssocs.length; type++){
//if association type exits in node
if(typeof docAssocs[refAssocs[type]] != "undefined"){
var assocTypeList = docAssocs[refAssocs[type]];
//iterate trough script nodes for association type
for(var assoc = 0; assoc < assocTypeList.length; assoc++){
assocFileNames.push[assocTypeList[assoc].name];
logger.log(assocTypeList[assoc].name);
}
}
}
//behavior.args[0].properties["my:references"] = assocFileNames.join(",");
logger.log(assocFileName);
behaviour.args[0].save();
}
<bean id="onMyAssociationCreate" class="org.alfresco.repo.policy.registration.ClassPolicyRegistration" parent="policyRegistration">
<property name="policyName">
<value>{http://www.alfresco.org}onCreateAssociation</value>
</property>
<property name="className">
<value>{http://www.alfresco.com/model/docs/1.0}myDoc</value>
</property>
<property name="behaviour">
<bean class="org.alfresco.repo.jscript.ScriptBehaviour" parent="scriptBehaviour">
<property name="location">
<bean class="org.alfresco.repo.jscript.ClasspathScriptLocation">
<constructor-arg>
<value>alfresco/extension/scripts/onMyAssociationCreate.js</value>
</constructor-arg>
</bean>
</property>
</bean>
</property>
</bean>
03-20-2012 03:49 PM
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.