cancel
Showing results for 
Search instead for 
Did you mean: 

update properties of existing contents

sulyman_korj
Champ in-the-making
Champ in-the-making
Dears,

can you help me I need to find solution to update properties value for existing contents.
for example:

I have 10 contents on one folder I need to set Description properties value to (Any Words) in alfresco we can set rule when I add any content to set properties value but I need to do like this but for many existing contents on one time.

can any one help me.

7 REPLIES 7

icrew
Champ in-the-making
Champ in-the-making
Hi sulyman.korj:

The Modifying and Creating API should help.  See:
http://docs.alfresco.com/4.2/references/API-JS-ModifyCreate.html

The example they give on that page is poorly formatted, but shows exactly what you want to do.  Here it is formatted better:

<javascript>
// change the name of this document
document.properties.name = "Backup of " + document.properties.name;
// add a new property string
document.properties["cm:locale"] = mylocalenode;
// save the property modifications
document.save();
</javascript>

Also, the Javascript Console Add-on (http://addons.alfresco.com/addons/javascript-console) is extremely useful as you're working on a script like this.

Hope this helps!

Ian

sulyman_korj
Champ in-the-making
Champ in-the-making
Thank you for your reply but my problem I need the idea how I can implementing this where I can put the script for example if I need to select some files and update properties values for them.
I try to find one example after this I can modified as I need because I have custom metadata.

icrew
Champ in-the-making
Champ in-the-making
http://wiki.alfresco.com/wiki/JavaScript_API_Cookbook and http://wiki.alfresco.com/wiki/Iterate_Nodes have some good examples of the sorts of things you can do with the JavaScript API.  Also check out the samples in COMPANY_HOME/Data Dictionary/Scripts inside your alfresco instance.

sulyman_korj
Champ in-the-making
Champ in-the-making
Please any one can help me

romschn
Star Collaborator
Star Collaborator
There are various different ways you can do this -
1. Write a webscript and pass the parent folder node to it,Iterate over its children and set the required properties on them.
2. Another way is to write a java script based action, run it on a parent folder through Run Action. Using the parent node, iterate over its children and set the required properties on them.

Hope this is what you are looking forward to. Hope this helps.

sulyman_korj
Champ in-the-making
Champ in-the-making
Thank you for your reply can you give me sample or give me the details.

muralidharand
Star Contributor
Star Contributor
Hi,
Please find the below sample code to update the description.
Note: It updates the description for both the folders and the files as well.

<javascript>
for (var i=0; i<document.children.length;i++) {     
    var currentFolder = document.children;     
    currentFolder.properties["cm:description"] ="Description updated via javascript";
    currentFolder.save();
}


</javascript>