01-29-2020 04:49 AM
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.
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
01-30-2020 09:05 AM
Solved it , using following path
companyhome.childByNamePath("Sites/YourSite/documentLibrary/BusinessDocument/CLAIM")
I have just ignored the 'Site' path .
01-29-2020 08:59 AM
Check out this previous post and see if it provides the answers you need.
01-29-2020 09:23 AM
Thanks for the reponse , But i am looking for Javascript API samples . Link mentioned is regarding REST API to create folder.
01-29-2020 09:38 AM
Does this help? I am trying to find some Javascript that I have used.
01-29-2020 09:40 AM
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);
01-29-2020 10:54 AM
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
01-30-2020 09:05 AM
Solved it , using following path
companyhome.childByNamePath("Sites/YourSite/documentLibrary/BusinessDocument/CLAIM")
I have just ignored the 'Site' path .
Explore our Alfresco products with the links below. Use labels to filter content by product module.