• Skip to primary navigation
  • Skip to main content
  • Skip to footer
ecm experts in australia

Seed Information Management

Enterprise Content Management Consultants ECM Experts

  • Services
    • Content Management
    • Collaboration
    • Business Process Management
    • Migration Services
    • Integration Services
    • Support & Maintenance
    • Pricing
  • Technology
    • Alfresco Digital Business Platform
    • Alfresco Application Development Framework
    • Cloud (PaaS)
    • Activiti
    • Flowable
    • Hyland RPA
  • Alfresco Addons
  • Case Studies
    • Industries
  • Blog
  • Contact Us
    • About

Alfresco javascript console remove aspect example

May 25, 2018 By Seed IM

Let say that we have an aspect and we want to remove that aspect from some nodes that have certain ids

Just showing the nodes

logger.debug("INIT rm aspect");

var idList = [
  "1788",
        "1789",
        "1790"
];

for(i = 0; i < idList.length; i++){
  var query = "ASPECT:\"ca:customAspect\" AND @ca\\:docId:\""+ idList[i] +"\"";
  logger.debug("QUERY:" + query);
  var results = search.luceneSearch(query);
  if (results.length >= 1) {
    var node = results[0];
    var name = node.properties["cm:name"];
    logger.debug("FILENAME:" + name + " NODEREF:" + node.nodeRef);
  }
}

We recommend first just print the name of the document that will be changed as show in the previews code.

In general is a good idea if you use javascript console to write changes in the repository, to do an version of the script that doesn’t change the nodes but highlight the node upon the change will be made to do a check that you are not doing something wrong.

And then after checking that the list hasn’t any undesired node you canĀ  proceedĀ  to eliminate the aspect from that list of nodes.

Actually deleting the aspect

logger.debug("INIT rm aspect");

var idList = [
  "1788",
        "1789",
        "1790"
];

for(i = 0; i < idList.length; i++){
  var query = "ASPECT:\"ca:customAspect\" AND @ca\\:docId:\""+ idList[i] +"\"";
  logger.debug("QUERY:" + query);
  var results = search.luceneSearch(query);
  if (results.length >= 1) {
    var node = results[0];
    var name = node.properties["cm:name"];
    logger.debug("FILENAME:" + name + " NODEREF:" + node.nodeRef);
    node.removeAspect("ca:customAspect");
    node.save();
  }
}

Javascript is a really quick and powerful tool, and for the same reason it is really easy to make regrettable mistakes with it.

 

Footer


Seed IM is a leading ECM consulting company providing powerful solutions to businesses and organisations of all sizes

Contact Us

  • Seed Information Management Pty Ltd
    90 Maribyrnong Street
    Footscray VIC 3011
  • 03 9021 0837
  • info@seedim.com.au

Articles

Semantic Content Management for Alfresco
Using Multiple Taxonomies To Browse Your Content
Records Management Using Alfresco One

Copyright © 2025 Seed Information Management Pty Ltd · Contact Us · Privacy Policy · Our Digital Media Agency is Marmoset Digital