Folder structure creation under specific path

cancel
Showing results for 
Search instead for 
Did you mean: 
brijeshnk
Established Member

Folder structure creation under specific path

Jump to solution

Hi There , I have requirement for creating folder structure periodically using scheduler. Scheduler configrued to execute a script , script will create document in specific folder ,  My root folder shown below  image . I need to create a folder '2020' under 'claim' folder  using Alfresco Javascript API.

 

FolderStruct.JPG

Question is  : -

1- How do i navigate to 'claim' using javascript API.  I have tried following script

var envSubFolder = companyhome.childByNamePath("CLAIM");

var claimPath  = envSubFolder.displayPath

'claimPath' always return 'PATH/Company Home'  

How will  i navigate to  'Document/Buisness Documents/Claim' and create a child folder under 'Claim' folder ? Any blog or link is highly apprecirated .

My folder structure shows below.

 

 

thanks a lot

1 Solution

Accepted Solutions
brijeshnk
Established Member

Re: Folder structure creation under specific path

Jump to solution

Solved it , using following path

companyhome.childByNamePath("Sites/YourSite/documentLibrary/BusinessDocument/CLAIM")

I have just ignored the 'Site' path .

 

View solution in original post

6 Replies
jljwoznica
Senior Member

Re: Folder structure creation under specific path

Jump to solution

Check out this previous post and see if it provides the answers you need.

https://hub.alfresco.com/t5/alfresco-content-services-forum/how-to-create-folder-under-a-specific-si...

brijeshnk
Established Member

Re: Folder structure creation under specific path

Jump to solution

Thanks for the reponse , But i am looking for Javascript API samples  .  Link  mentioned is  regarding REST API to create folder.

jljwoznica
Senior Member

Re: Folder structure creation under specific path

Jump to solution

Does this help? I am trying to find some Javascript that I have used.

https://www.npmjs.com/package/alfresco-js-api#create-folder

jljwoznica
Senior Member

Re: Folder structure creation under specific path

Jump to solution

I am not sure this helps, but it was attached to a rule on a folder ... 

document.properties['fn:ReportName']=rname;

// function to create folder structure
function createFolder(parentNode, folderName, folderTitle)
{
var newFolder = parentNode.childByNamePath(folderName);
logger.log("Folder exists " + newFolder);
if (newFolder == null)
{
// create the folder for the first time
logger.log("Creating a new folder: " + folderName);
newFolder = parentNode.createFolder(folderName);
if(folderTitle != null)
{
logger.log("title: " + folderTitle);
newFolder.properties["cm:title"] = folderTitle;
newFolder.save();
}
}
return newFolder;
}

var parentNode = document.parent;
var higherParent = parentNode.parent;
var reportsNode = higherParent.childByNamePath("Reports");

//var reportNodeRef = "workspace://SpacesStore/f5b8dac7-ba6b-4a12-9655-cfe33d9b3307"
//var parentNode = search.findNode(reportNodeRef);
//parentNode = createFolder(parentNode, reportID);

// create folder for reportID with title long name
parentNode = createFolder(reportsNode, reportID, rname);
// create folder for date
parentNode = createFolder(parentNode, rdate, null);

document.save();
document.move(parentNode);

brijeshnk
Established Member

Re: Folder structure creation under specific path

Jump to solution

I understand , this is for creating folders in Alfresco Repo . My requirement is more to create a folder under  Share . Under Sire / Document Library  .

Script which i am executing is currently creating folders under repo . I can see that when i logged in as Admin . Under repository all the folders are created .

Is there any difference in Repo Folder structure and Alfresco Share Folder under Site/Document Library ?

 

thanks

brijeshnk
Established Member

Re: Folder structure creation under specific path

Jump to solution

Solved it , using following path

companyhome.childByNamePath("Sites/YourSite/documentLibrary/BusinessDocument/CLAIM")

I have just ignored the 'Site' path .