0

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.

enter image description here 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.

1 Answers1

0

When you use "companyhome", you are actually using a root object, described here. If you take a look, you'll see that it's type is "org.alfresco.repo.jscript.ScriptNode".

https://docs.alfresco.com/6.1/references/API-JS-rootscoped.html

If you now look at the "childByNamePath" method, you'll see that path is used to find your child. So your code actually tries to find "CLAIM" immediately under the Company Home, and that node really does not exists (since it's under the "Business Document" folder).

https://docs.alfresco.com/6.1/references/API-JS-childbyNamePath.html

Lista
  • 2,186
  • 1
  • 15
  • 18
  • Thanks for the respone , I used following syntax . This also returns null var testingFolder =userhome.childByNamePath("/Company Home/Documents/UIA Business Document/CLAIM"); – Brijesh N K Jan 29 '20 at 12:28
  • You are now using "userhome", which is a different root object; where exactly is that folder? – Lista Jan 29 '20 at 13:38
  • I have attached image of my folder structrure in my orginal post above . Its under 'Document/Business Documents/' . Refer image in my original post – Brijesh N K Jan 29 '20 at 13:51
  • just to give you more pointer , i want to create this under Alfresco Share . Not in Repo – Brijesh N K Jan 29 '20 at 15:51
  • 1
    The "Documents" folder that you see under "Library" (in your screenshot) is actually the "documentsLibrary" node of your Site. So your PATH query needs to take this into account. Something like: companyhome.childByNamePath("Sites/YoutSite/documentLibrary/BusinessDocument/CLAIM") – Lista Jan 30 '20 at 09:51