I have the code below in my Sandbox environment. I'm test running it in Developer Console. My sandbox environment is connected to my Box.com account. What I'm attempting to do is create a new folder (and sub-folders) in Box.com by executing the code below. The code executes successfully in Developer Console, but it doesn't create a folder in Box. The code seems relatively simple and straight-forward, but I get no new folder in Box, and I get 'Null' for all values.


//Instantiate the Toolkit object
    box.Toolkit boxToolkit = new box.Toolkit();

//Create a folder and associate it with an account
    Id accountId = '001j000000FBozz';
    String accountFolderId = boxToolkit.createFolderForRecordId(accountId, null, true);
    system.debug('new item folder id: ' + accountFolderId);

//Create two sub-folders in the newly created account folder
    String legalFolderId = boxToolkit.createFolder('Legal Documents', accountFolderId, null);
    system.debug('Legal Folder id: ' + legalFolderId);
    String pictureFolderId = boxToolkit.createFolder('Pictures', accountFolderId, null);
    system.debug('Picture Folder id: ' + pictureFolderId);

//Collaborate the current user on the account folder
//Note that we're sending false for the optCreateFolder param
// that shouldn't actually matter since the folder(s) already exists
    Id userId = UserInfo.getUserId();
    box.Toolkit.CollaborationType collabType = box.Toolkit.CollaborationType.EDITOR;
    String collabId = boxToolkit.createCollaborationOnRecord(userId, accountId, collabType, false);
    system.debug('new collaboration id: ' + collabId);

//ALWAYS call this method when finished.
//Since salesforce doesn't allow http callouts after dml operations,
// we need to commit the pending database inserts/updates or we will
// lose the associations created

============= END CODE ==================

enter image description here


  • Is your account id the correct one ? – Mihai Neagoe Apr 20 '16 at 15:05
  • I've tried the one that Box.com uses, and I've also gone inside one of our company's accounts (the accounts tab), copied the id at the end of the URL, and tried that, if that's what you mean by accountId... – Rocket_Izz Apr 20 '16 at 15:52
  • Oh, I think I see what you're saying. So, what I just did was perform this SOQL query to find an account id: SELECT id FROM account, I grabbed one of the resulting ids, and then used it in the code above. Still no folder gets created in box. – Rocket_Izz Apr 20 '16 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.