Getting node from backend in document manager

I want to be able to access the node and not just the ID in the backend methods. Is there a way to do this?

Hi,

This question was answered earlier in a different conversation, so I will copy the information here for those who interested in it.

The backend methods provide access only to the folder or file ID they work with.

But you can access the node via the LocalData service, which is available though FileManager/DocumentManager (DM inherits primary API) instance as:

const data = $$("fm").getService("local");

If you are working with a folder - e.g. files() and search() methods - then you can access the hierarchy TreeCollection to get item node:

const node = data.hierarchy.getItem(id);

If you need a file node - read(), rename(), copy() methods - then you need to first access the cached files of the current folder assuming that it contains the file in question. The files DataCollection is available as:

const folder = $$("fm").getState().path;
const files = data.fscache.get(folder);

Then you will be able to get the node with the same .getItem() method.

Please check the following snippet for details: Code Snippet