Book Image

Alfresco 3 Cookbook

Book Image

Alfresco 3 Cookbook

Overview of this book

Alfresco is the renowned and multiple award winning open source Enterprise content management system which allows you to build, design, and implement your very own ECM solutions.You have read a number of tutorials, blogs, and books on Alfresco. Now you're in the real world, trying to use Alfresco, but you’re running into problems with it. This is the book you want. Packed full of solutions that can be instantly applied, this cookbook with its practical based recipes and minimal explanation meets that demand.This Alfresco 3 cookbook boasts a comprehensive selection of recipes covering everything from the basics to the advanced. The book has recipes for quickly installing Alfresco in Windows and Linux and helping you use custom content model, rules, and search. There is also a collection of recipes focused on creating Scripts, Freemarker templates, Web Scripts, and new workflow definitions. Steps to integrate Alfresco with other systems like MS-Office are also included. You will be able to use Alfresco’s File and Email servers. Finally, step-by-step recipes are presented to create an Alfresco build environment and compile the source code. This Alfresco 3 Cookbook is perfect for developers looking to start working on Alfresco quickly, gain complete understanding, write custom implementations, and achieve expertise very easily.
Table of Contents (21 chapters)
Alfresco 3 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding a tag to a document


In this recipe, we will write a script that can be used to tag a document.

How to do it...

  1. 1. Create a new script file in the Company Home>Data Dictionary>Scripts>Cookbook folder and add the following code; let’s say the file is named addtag.js

    if (!document.hasAspect("cm:taggable"))
    document.addAspect("cm:taggable");
    document.addTag("test");
    
  2. 2. Execute the script using Run Action on the document Test_JS_API.txt in the Chapter 8 folder.

  3. 3. The document will not be taggable, and a new tag has been added with the document—test. This is reflected in the property sheet of the document.

  4. 4. Now, you can also add more tags using the property editor dialog.

How it works...

The code we presented is rather simple in this case. As usual, the document object here automatically refers to the current document. In our case, it is Test_JS_API.txt, since we have executed the script against this document.

First we have checked whether the document already has the cm:taggable aspect...