Find folders in content explorer using metadata queries

Hi @rbarbosa,

I am also trying to fetch files and folders in content explorer, using metadata query in node/react. I am facing 2 issues:

  1. getting back all files and folders for a sponsorCode metadata as a response. But only files are getting displayed in content explorer. Folders are not getting displayed.

  2. I have 3 folders with different values for sponsorCode metadata(Folder 1- TESTF metadata, Folder 2- TESTR metadata, Folder 3- TESTM metadata.
    I am only able to fetch files/folders for TESTR metadata. Other searches are resulting in no data in response. I have waited for more than 48 hours after applying metadata.

Can you pls help solve this?

Hi @ricgau ,

Further discussing with @ostefaniuk after our session, there seems to be an issue in the way the content explorer references the metadata fields. But before I jump into conclusions, let me ask around to the specialists in the area.

Thank you @rbarbosa. Please let me know at the earliest possible.
Also, is the files and folders view in the content explorer for a specific metadata structured? Ex. Folder A has a file1 and folder B. Then folder B has another file -file2. So will the display in content explorer be file 1 and Folder B(which contains file2).
OR
is it flattened? if yes, is there a way to get it structured similar to how its stored in box?

Hi

Regarding the returned values. Currently the Metadata query view in the UI elements can only display a flat list of files that matches the query. It wil not return folders. The API itself does support querying for folders but the UI element does not in its current version.

Rgds
Peter Christensen, Platform Solutions Engineer, Box

Hi @ ricgau,

Thank you for your question! As @pchristensen, mentioned currently we support only file view.

  1. I have 3 folders with different values for sponsorCode metadata(Folder 1- TESTF metadata, Folder 2- TESTR metadata, Folder 3- TESTM metadata.
    I am only able to fetch files/folders for TESTR metadata. Other searches are resulting in no data in response. I have waited for more than 48 hours after applying metadata.

Regarding your second question, I’m wondering what is the query for the metadata component you’re using. If the query looks the following the view will filter the files with the TESTR value:

    query: "sponsorCode = :arg1",
    query_params: { arg1: "TESTR" },

To display all sponsorCode values in a column, choose a different metadata key that would match all of these files in the query and add sponsorCode to fields and fieldsToShow arrays. Let me know if that helps.

Best,
Olga

@ostefaniuk : I have 3 folders with 3 different metadata values and I am using 3 queries separately.
Only 1 query works and returns the data with TESTR sponsorcode. The other 2 queries fetches no result.

@pchristensen Do we have anything coming up soon to help us view the structured data in matadata view?

Currently, the files returned can be previewed and other actions in preview mode can be carried out. But we cannot search or add files using the content explorer. Attaching the ui display screenshot for reference.

Also we want display similar to below screenshot: (painted the names of users for privacy in screenshot)

Could you please make an API call and extract the metadata values for one of the files with using endpoint? Here is a snippet I used with TS SDK.

import { BoxClient, BoxDeveloperTokenAuth } from "box-typescript-sdk-gen";

const getFileMetadata = async function main(TOKEN, FILE_ID) {
    try {
      const client = new BoxClient({
        auth: new BoxDeveloperTokenAuth({ TOKEN }),
      });
      const metadata = await client.fileMetadata.getFileMetadataById(
        FILE_ID,
        'enterprise_EID',
        'metadataTemplateName'
      );
      console.log(metadata)
    } catch (e) {
      console.error(e);
    }
  }

getFileMetadata(token, file_ID)

The API is going to return all key and value pairs for a particular file. It’s important to note that the key might differ from the metadata label that is actually displayed in the Admin Console. This behaviour is intended, the key is generated upon creation and remains constant to guarantee that your code will work despite someone editing the label. Also, note some keys might differ just with letter case. For the snake case values the special character might have been removed in the actual key. Once you update the code with the keys instead of labels the component should display the values.

Best,
Olga

Do we have anything coming up soon to help us view the structured data in matadata view?

You’re more than welcome to submit your request in Box Pulse. Let me also pass your feedback directly to PM for visibility.

Hi @ricgau,

Did the suggestions helped you to solve the issue? Is there anything else I can help you with?

Best,
Olga