Skip to main content
Solved

How to Retrieve Subfolder IDs from a Box Folder Using box.Toolkit

  • Oct 20, 2026 8:21 AM UTC
  • 2 replies
  • 79 views
  • Translate All

Hi ,

I would like to retrieve the IDs of subfolders within a Box folder associated with a Salesforce record.

I believe the box.Toolkit class's getFolderContents method might be useful for this purpose, but I'm not sure what information is returned in the FolderContents object.

Could anyone clarify the following?

  1. What information does the FolderContents object contain?
  2. Is it possible to retrieve a folder ID by using the folder name as a key from the FolderContents object?

Any advice or code examples would be greatly appreciated.

Thank you in advance for your help!

Best answer by Jason S

Hi ​@reina.ueno,

Yes, box.Toolkit.getFolderContents() can help retrieve the items inside a Box folder. The FolderContents object represents the folder’s contents as a list of entries; each entry includes information about an item, such as its name, type, and ID. Folder IDs are part of each folder entry.

You can loop through the entries and match the folder by name. The folder name isn’t a key you can use to look up an ID directly, and names may not be unique, so check the item type and confirm the parent folder if needed.

box.Toolkit toolkit = new box.Toolkit();
box.FolderContents contents = toolkit.getFolderContents(parentFolderId);

for (box.Folder item : contents.folders) {
if (item.name == 'Subfolder Name') {
System.debug('Folder ID: ' + item.id);
}
}

The exact property names may vary by Toolkit version. If FolderContents doesn’t expose folder entries in your installed package, check the class definition in Salesforce or use the Box SDK for Salesforce to call the Box folder items endpoint. The Toolkit is intended for common integration customizations and isn’t a full Box Content API wrapper. Box Dev Docs

See the Salesforce Developer Toolkit documentation and code samples.

View original

2 replies

Jason S
Forum|alt.badge.img
  • Box Employee
  • Answer
  • Oct 20, 2026 2:43 PM UTC

Hi ​@reina.ueno,

Yes, box.Toolkit.getFolderContents() can help retrieve the items inside a Box folder. The FolderContents object represents the folder’s contents as a list of entries; each entry includes information about an item, such as its name, type, and ID. Folder IDs are part of each folder entry.

You can loop through the entries and match the folder by name. The folder name isn’t a key you can use to look up an ID directly, and names may not be unique, so check the item type and confirm the parent folder if needed.

box.Toolkit toolkit = new box.Toolkit();
box.FolderContents contents = toolkit.getFolderContents(parentFolderId);

for (box.Folder item : contents.folders) {
if (item.name == 'Subfolder Name') {
System.debug('Folder ID: ' + item.id);
}
}

The exact property names may vary by Toolkit version. If FolderContents doesn’t expose folder entries in your installed package, check the class definition in Salesforce or use the Box SDK for Salesforce to call the Box folder items endpoint. The Toolkit is intended for common integration customizations and isn’t a full Box Content API wrapper. Box Dev Docs

See the Salesforce Developer Toolkit documentation and code samples.

Translate

  • Author
  • New Participant
  • Oct 28, 2026 1:30 AM UTC

​@Jason S 

Thank you for your advice!

Sorry for the late reply. It took me some time to figure out the solution.

In my environment, I was able to retrieve the information I needed using the following code:
 

box.Toolkit toolkit = new box.Toolkit();
box.Folder folder = toolkit.getFolderContents(parentFolderId);
for (box.Entry entry : folder.entries) {
    if (entry.name == 'Subfolder Name') {
        System.debug('Folder ID: ' + entry.id);
    }
}


This was a great help. Thank you so much!

Translate