Hello everyone! I've implemented a custom model with an association called relatedDocuments. Now, i have to crate a javascript to retrieve the list of the relatedDocuments associated to a specific document. Does an API to do this exist?
I've tried with "document.properties["tr:relatedDocument"]" but it has returned NULL.
I need that because i'm trying to create a link between my document based on their metadata. I've set up a rule that, on update of content in a folder, will search in the repository if exists a document the could be linkable to the one updated.
The first execution works ok. Following executions result in error probably because there isn't an if statement to check if the association is a duplicate one.
I'm using the following scripts:
<blockcode>
function main()
{
var cod_off = document.properties["tr:cod_off"];
logger.log("######## VALUE OF COD OFF #########" + cod_off);
var query = "@tr\\:cod_off:" + cod_off;
logger.log("###### VAR QUERY CONTENT ######" + query);
var results = search.luceneSearch(query);
var resultTitle;
var documentTitle = document.properties["cm:title"];
var relatedDocs = document.properties["tr:relatedDocument"];
var count = relatedDocs.length;
logger.log("### VALUE OF COUNT RELATED DOCS ####" + count);
for (var i = 0; i<results.length; i++)
{
resultTitle = results.properties["cm:title"];
if(resultTitle !== documentTitle)
{
logger.log("#### FOUND DOCUMENT TITLE ######" + resultTitle);
document.createAssociation(results, "tr:relatedDocument");
results.createAssociation(document, "tr:relatedDocument");
}
}
}
main();
</blockcode>
If anyone knows how to retrieve the list of associated document to another, please answer me.
Best regards.