cancel
Showing results for 
Search instead for 
Did you mean: 

Target type with specific property in association

prasobhraj
Star Contributor
Star Contributor
Hi,

Is it possible make association as target type with specific property? for eg: some type X has a property which is either true or false. I want to associate the type with property value true only. Please advice
1 ACCEPTED ANSWER

jpotts
World-Class Innovator
World-Class Innovator

It would be far more instructive for you to give it a shot and then report back if you get stuck.

To get you started, here is a JavaScript snippet that does a search:

var query = "+TYPE:\"cm:folder\" +@cm\\:name:\"" + PARENT_FOLDER_NAME + "\"";

var results = search.luceneSearch(query);

if (results.length != 1) {

       logger.log("Expected to find exactly one folder named " + PARENT_FOLDER_NAME + " but instead found " + results.length);

       return;

}

You may also want to install the JavaScript console. It can be used as a nice little JavaScript testing Ui directly within Alfresco Share:

GitHub - share-extras/js-console: Administration Console component for Alfresco Share, that enables ...

And here are some docs:

Search API | Alfresco Documentation

Modifying and creating API | Alfresco Documentation

View answer in original post

3 REPLIES 3

jpotts
World-Class Innovator
World-Class Innovator

It sounds like you want to create an association between two objects if and only if the property on one of the objects has a certain value. You can do this on an ad hoc basis by writing a script that performs a search for documents with the property value, then creates the association if it does not exist.

If you want to do this every time a document is created, you can write a behavior to check the property value, then create the association.

Hi Jeff,

Am setting a property with a default value when ever a document being uploaded in a space by applying a rule.

"You can do this on an ad hoc basis by writing a script that performs a search for documents with the property value, then creates the association if it does not exist." can you please help to make the script or showing some sample script

jpotts
World-Class Innovator
World-Class Innovator

It would be far more instructive for you to give it a shot and then report back if you get stuck.

To get you started, here is a JavaScript snippet that does a search:

var query = "+TYPE:\"cm:folder\" +@cm\\:name:\"" + PARENT_FOLDER_NAME + "\"";

var results = search.luceneSearch(query);

if (results.length != 1) {

       logger.log("Expected to find exactly one folder named " + PARENT_FOLDER_NAME + " but instead found " + results.length);

       return;

}

You may also want to install the JavaScript console. It can be used as a nice little JavaScript testing Ui directly within Alfresco Share:

GitHub - share-extras/js-console: Administration Console component for Alfresco Share, that enables ...

And here are some docs:

Search API | Alfresco Documentation

Modifying and creating API | Alfresco Documentation