Run javascript code error to get folder path

Hi !

I am trying the display the full path to the current folder opened by the user.
The page is called “Template”, and I store in a custom state the currently selected folder “current folder”

Here the js code:

And I use the JS to bubble element

And i display in a repeating group the list

But the thing is I get an error in the console and my list is empty

The good thing about errors is that they can help you debugging the problem.
If you are looking for help you may consider sharing the error.

At a first glance it looks like you are a bit confused ablout what you are doing: unique ids in bubble are strings. So in your code rootParent is a string and doesn’t have a property called parentFolder. Of course the subsequent undefined doesn’t have a property unique.
But before that the problem is that rootParent = rootParent.parentFolder.unique id; will throw a SyntaxError.

1 Like

You don’t really need any scripting to do this. If you have a data structure like this:

Then you can “navigate” folders like this (this demonstration uses List Shifter to do its thing):


Thanks @keith, I used your solution.
I have only one issue. The path list generated contained only 3 elements max, I can’t find the reason.
Any idea why ?

This topic was automatically closed after 70 days. New replies are no longer allowed.