AnsweredAssumed Answered

Question about javascript and assocs.

Question asked by katootje on Jul 16, 2007
Latest reply on Jul 17, 2007 by kevinr

In an attempt to figure out how to handle groups of documents I wanted to find the associations of a document using javascript. I can successfully make associations in the client but I can't seem find them with my script.

I've installed the stable alfresco 2.1 community release.
This is the type I defined:
      <!– Definition of new Content Type: Press Release –>
      <type name="eb:Opdracht">
            <property name="eb:OpdrachtId">
               <title>Opdracht id</title>
            <association name="eb:Image">
            <association name="eb:Bijlage">

    <config evaluator="string-compare" condition="Content Wizards">
            <type name="eb:Opdracht" />

    <config evaluator="node-type" condition="eb:Opdracht" >
            <show-association name="eb:Image" />
            <show-association name="eb:Bijlage" />

And this my javascript:
// log the docs that currently contain the word 'Alfresco' to a log file
var logFile = space.childByNamePath("ListProperties.txt");
if (logFile == null) {
   logFile = space.createFile("ListProperties.txt");

if (logFile != null) {
    var log = "";
    log += "document properties: \r\n";
    for (var propName in {
        var propValue =[propName];
        log += propName + "=" + propValue + "\r\n";

    log += "plaatjes\r\n";
    for (var node in document.assocs["eb:Image"]) {
        for (var propName in {
            log +=  "child " + propName + "=" +[propName] + "\r\n";

     log += "any?\r\n";
     for (var node in document.assocs) {
         for (var propName in {
             log +=  "child " + propName + "=" +[propName] + "\r\n";

    logFile.content += log;

When running the script in a run action on a document (with associations) I do get the properties of my document in the ListProperties.txt file, but no associations. Should you be able to find them this way? A hint would be welcome.