Is there a way to delete Content Rules using Javascript API ?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2013 08:22 AM
Hello
I will migrate my data to the latest version of Alfresco and at the same time, I want to delete all the Content Rules that exists in my current data tree as they will become useless.
I am able to change rights using javascripts without problems (via calls to SetPermission(), etc..), but I have not found any solution to delete a content rule. Could you please help me ?
Thank you for your help
Matthew
I will migrate my data to the latest version of Alfresco and at the same time, I want to delete all the Content Rules that exists in my current data tree as they will become useless.
I am able to change rights using javascripts without problems (via calls to SetPermission(), etc..), but I have not found any solution to delete a content rule. Could you please help me ?
Thank you for your help
Matthew
Labels:
- Labels:
-
Archive
11 REPLIES 11
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2013 04:57 AM
Hello
no success until now… I give up and will keep my useless content rules for now.
Thanks for your help and to have taken time trying to help me !
Matt
no success until now… I give up and will keep my useless content rules for now.
Thanks for your help and to have taken time trying to help me !
Matt
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2013 02:38 AM
In fact you can still use javascript api to delete rules ,in alfresco rules are saved as nodes .rules applied to a node A is saved under A with child associations named {http://www.alfresco.org/model/rule/1.0}ruleFolder.
So you can delete rules applied to a node by using ScriptNode api to delete sub nodes,this is not a direct way.
following is a profile of an example
if you want to delete all rules,follow step 1.2.16.17
if you want to remove some rules,follow all steps except 16.17
You 'd better run a test before you use these code to make sure they do the right thing.
So you can delete rules applied to a node by using ScriptNode api to delete sub nodes,this is not a direct way.
following is a profile of an example
if you want to delete all rules,follow step 1.2.16.17
if you want to remove some rules,follow all steps except 16.17
1.var ruleFolder = mynode.childAssocs["{http://www.alfresco.org/model/rule/1.0}ruleFolder"][0];//mynode is the node whose rules you want to delete2.mynode.removeNode(ruleFolder);3.rules = ruleFolder.childAssocs["{http://www.alfresco.org/model/rule/1.0}ruleFolder"];4.for(i=0;i<rules.length;i++)5.{6. var obj = rules;7. var reg = new RegExp("^rules.*");8. if(reg.exec(obj.properties.name)){//node name matches ^rules.* regular expression is rule node9. // add your code here to idenfify rule you want to delete10. if(***){11. rules.removeNode(obj);12. }13. }14.}15.rules.save();16.mynode.removeAspect("{http://www.alfresco.org/model/rule/1.0}rules");//remove mynode's rules aspect;17.mynode.save();
You 'd better run a test before you use these code to make sure they do the right thing.
