繁体   English   中英

使用JavaScript在露天数据列表关联中添加多个文档

[英]Adding more than one document in alfresco datalist association using javascript

我是露天的新手。 我有一个使用数据列表处理员工记录的自定义模型。 如果要添加的记录是新记录,我可以读取扫描的文件名,并使用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();
    }

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

如果将内容模型中定义的关联的多重性设置为允许关联上有多个目标对象,则只需创建其他关联即可。 例如,这是内容模型的一个片段,由于“ many”设置为true,因此该片段将允许关联多个文档:

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

如果将“ many”设置为false,则在尝试创建其他关联时会收到错误消息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM