cancel
Showing results for 
Search instead for 
Did you mean: 

[Javascript]Get name of space where rule resides in

camillo
Champ in-the-making
Champ in-the-making
Hi all,

how can i get the path of the space in which rule resides ?
For example, in a rule that's in a space named "TEST", i would like

var rule_path = [space_of_the_rule];
rule_path.createFile('my_file.txt');

In this way I can create my_file.txt inside the space in which rule resides.
I hope my explation is clear
Thanks in advance for your help
5 REPLIES 5

zomurn
Champ in-the-making
Champ in-the-making
If you have a look in the administration console, in the node navigator, you will see in your "Test" folder the rule appearing as a node like :

{http://www.alfresco.org/model/rule/1.0}ruleFolder   workspace://SpacesStore/3491e8e5-ec96-11dd-bf4a-83b750caf13c   true   {http://www.alfresco.org/model/rule/1.0}ruleFolder   0

Click on workspace://SpacesStore/3491e8e5-ec96-11dd-bf4a-83b750caf13c and then you have the detail of the rule node attributs.
You may query directly from the type of the node the rule is assimilated to : "TYPE:cm:systemfolder" then you have a reference to the rule and with "getPrimaryParent" you have a reference to the parent folder.

camillo
Champ in-the-making
Champ in-the-making
Thanks for your answer, but, sorry, I don't uderstand how I can get the path of the rule using javascript  Smiley Sad
Could you explain clearly?
I also apologize for my english
Thanks again

zomurn
Champ in-the-making
Champ in-the-making
with luceneSearch javascript method…have a look at javascript Search API

camillo
Champ in-the-making
Champ in-the-making
Hi zomurn,

thanks for preciouses advices.
But if the rule is hereditated from parent how can I get the path of the space?
This line

var docs = search.luceneSearch("PATH:\"/app:company_home/cm:my_folder/*\" AND TYPE:\"cm:systemfolder\"");
allows to get the path of the rule but if a subspace of my_folder, called "mysub", hereditate the rule how I can know the path of mysub?
I hope my explanation is clear (my english is not so good :? )
Thank you very much for your posts!

zomurn
Champ in-the-making
Champ in-the-making
What you must assimilate and need to be clear for you is that in alfresco almost all is node.
By node, it means that you're are in a tree, programmatically speaking.
So, from the moment you have a reference on a node in alfresco and that you know where you are in the tree, you can easily navigate through the whole tree nodes like it appears in the node browser in the administration console…but instead of clicking to navigate through the tree, you need to code it to obtain a reference on a node.
Some methods are : parent() to get a reference to the parent node. children to get the list of the immediate children of the parent node, etc…
You can see exactly how your repository tree looks like through web client node browser. From here, your code is done by half !

PS : hava a look at node.path to get the path of a node.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.