使用javascript在alfresco datalist关联中添加多个文档
Adding more than one document in alfresco datalist association using javascript
我是第一次去户外。我有一个使用datalist处理员工记录的自定义模型。如果要添加的记录是新的,我可以读取扫描的文件名,并使用javascript附加相关元数据和关联中的文件。从扫描器扫描的文件具有以下信息21420-victor mathew-HR-copy of 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>
如果"many"被设置为false,当您尝试创建额外的关联时,您将收到一个错误。
相关文章:
- 如何判断何时将dom节点添加到文档中
- 如何从 URL 数组向文档添加图像列表
- 将事件侦听器添加到文档,而不是签入元素存在,然后添加事件侦听器
- PouchDB,如何在已经有附件的文档中添加新附件
- JS触发器值检查在文档加载后添加到页面的元素在加载时更改AND
- 如何以编程方式将内容脚本添加到 iframe 文档
- 是否有 jQuery 事件用于何时将元素添加到文档中
- 如何在猫鼬中更新文档后添加一些操作
- 使用单个HTML文档添加多个页面
- MongoDB:如何将这个散列添加到集合中的每个文档中
- 我该如何在旅途中添加一些段落,并将结果显示在带有段落标记的文档中
- 当我尝试添加文本效果时,有东西阻止了JavaScript的运行'手风琴'在html文档中
- 按标记名称将事件侦听器添加到所有文档子项
- 如何在HTML5文档中添加xml
- 使用JavaScript将自定义对象添加到文档中
- ABCPdf添加文档javascript
- 添加文档时,PouchDB 409冲突
- 在循环中向worklight jsonstore添加文档
- 通过javascript循环添加文档到ElasticSearch索引不工作
- 添加文档加载时无法检测复选框更改