Changing the Box for Salesforce Root Folder

Highlighted
First-time Contributor

Changing the Box for Salesforce Root Folder

Hi, 

 

I am able to get this integration to work using BOX toolkit for Salesforce, however, when writing test classes, my call to create folder (boxtoolkit.CreateFolder) fails. The message that I get is : Unable to get the Salesforce root folder, has the root folder been set on the Box Settings. Now, what I am not sure about is how can I set the root folder for boxtoolkit in a test class. Here is a snippet of the code.

@Istest static void test_createFileFromSFAttachment() {
Account ac = new Account(Name='DeliverableAccount');
insert ac;

Opportunity o = new Opportunity(Name='Opportunity 1', StageName='Relationship',
CloseDate=date.newInstance(2014,12,12));
insert o;

Deliverable__c d = new Deliverable__c(Opportunity__c=o.Id, Standalone_Account__c = ac.id);
insert d;

box__Folder_Details__c custSetting = new box__Folder_Details__c(Name='SalesforceBox',
box__FolderId__c = '123', box__Folder_Name__c='SalesForceTest');
insert custSetting;

box.Toolkit boxToolkit = new box.Toolkit(); //somehow I need to set the root folder
// and also set the service account.
boxToolkit.createCollaboration(custSetting.box__Folde//rId__c,
'xyz.com',
'***email address removed for privacy***',
box.Toolkit.CollaborationType.OWNER,
null);
String boxrecordFolderID = boxToolkit.createFolderForRecordId(d.id, null, true);
System.Debug('Capturing Box Folder ID;'+ boxrecordFolderID );
}

 

2 REPLIES 2
Highlighted
Occasional Contributor

Re: Changing the Box for Salesforce Root Folder

Hi,

     The Box root folder must be setup in the test class. There is a Box custom setting that defines the salesforce root folder and this value needs to be populated in order to avoid the failure that you have listed.

 

//Box custom settings
box__Folder_Details__c obj = new box__Folder_Details__c(Name = 'Salesforce', box__FolderId__c = '<random value>',box__Folder_Name__c = <Salesforce Root Folder>);
insert obj;

 

https://support.box.com/hc/en-us/articles/360043691254-Locating-the-Box-for-Salesforce-Root-Folder-I...

Highlighted
Occasional Contributor

Re: Changing the Box for Salesforce Root Folder

The URL provided in the earlier reply will show the box custom settings that i referred to.