使用javascript在alfresco数据列表关联中添加多个文档

使用javascript在alfresco数据列表关联中添加多个文档,javascript,alfresco,Javascript,Alfresco,我不熟悉户外。我有一个自定义模型,它使用datalist处理员工记录。如果要添加的记录是新的,我可以读取扫描的文件名,并使用javascript将相关metadat和文件附加到关联中。从扫描仪扫描的文件包含以下信息21420 victor mathew HR id-10.pdf副本 第一个值表示员工唯一id。我的问题是,扫描第二个文档时,我希望将其作为附件添加到数据列表中,但我的脚本正在创建新记录。这是我的javascript: var docname=document.properties[“

我不熟悉户外。我有一个自定义模型,它使用datalist处理员工记录。如果要添加的记录是新的,我可以读取扫描的文件名,并使用javascript将相关metadat和文件附加到关联中。从扫描仪扫描的文件包含以下信息21420 victor mathew HR id-10.pdf副本

第一个值表示员工唯一id。我的问题是,扫描第二个文档时,我希望将其作为附件添加到数据列表中,但我的脚本正在创建新记录。这是我的javascript:

var docname=document.properties[“cm:name”];//获取文件名 splitFile=docname.split(“-”);//拆分以获取元数据

fileCustomerNo    = splitFile[0];   
fileCustomerName  = splitFile[1];
fileDept          = splitFile[2]; 
fileDocType       = splitFile[5];   


    var testList = companyhome.childByNamePath("Sites/Employee/dataLists/823bd590-cbb7-4ea2-b9af-964ab4f1023a"); 
    var testEntry = testList.createNode(null, "tq:employee");


        var query= "@tq\\:fileCustomerNo:" + fileCustomerNo;                        
        var results = search.luceneSearch(query);           
        if(results !=null && results.length !=0)
        {

                var relatedarticles = companyhome.createNode("paymentDocs", "cm:content");
                relatedarticles.properties.content.write(document.properties.content);                  
                testEntry.createAssociation(relatedarticles, "tq:related" );                    
                relatedarticles.save();
        }else{


    testEntry.properties["tq:CustomerNo"] = fileCustomerNo; 
    testEntry.properties["tq:CustomerName"] = fileCustomerName; 
    testEntry.properties["tq:dept"] = fileDept;         
    testEntry.save();               

    var relatedarticle = companyhome.createNode("paymentDocs", "cm:content");       
    relatedarticle.properties["cm:name"] = docname;
    relatedarticle.properties.content.write(document.properties.content);       
    testEntry.createAssociation(relatedarticle, "tq:related");
    relatedarticle.save();
    }

有人帮助我如何将新文档添加到现有关联中,就像我可以在alfresco中单击“编辑和浏览”并添加文档一样。

如果内容模型中定义的关联上的多重性设置为允许关联上有多个目标对象,则只需创建附加关联即可。例如,以下是内容模型中的一个片段,它允许关联多个文档,因为“many”设置为true:

<target>
    <class>sys:base</class>
    <mandatory>false</mandatory>
    <many>true</many>
</target>

sys:base
假的
真的
如果将“many”设置为false,则在尝试创建附加关联时将收到错误