cancel
Showing results for 
Search instead for 
Did you mean: 

Changing Ownership to a Folder & subfolders

dsr_471
Champ in-the-making
Champ in-the-making
Hi I'm trying to change ownership to particular Folder(Main Folder)..
The folder structure is as shown below


Main Folder
   |—- Document 1
   |—- Folder 1
              |—– Document 2
              |—– Folder 2
                          |—– Document 3
                          |—– Folder 3
                                      |—– Soon……………………..

I'm using the below code to change ownership.

var f =roothome.childByNamePath("/Company Home/Sites/test1/documentLibrary/Main Folder");
          f.setOwner("owner2");
var own= f.getOwner();
         logger.log("New Owner is:"+own);

the ownership is changing only to  Main Folder , its not changing to files/folders inside that.

Please suggest how to change ownership for entire folder structure

Help is very appreciated.

thanks
2 REPLIES 2

ddraper
World-Class Innovator
World-Class Innovator
The owner of "Main Folder" is changing because that's the node that you're assigning to the variable "f". Try getting a reference to the nodes you want to change the ownership of.

Regards,
Dave

dsr_471
Champ in-the-making
Champ in-the-making
Thanks for reply,

As u said i will do it.
But the problem , what is the solution if there are large number of subfolders/files.

If i change the ownership of main folder , it should effect to all Sub-folders  automatically