Box Developer Blog
Published in

Box Developer Blog

Getting started with Box for Salesforce development: Part 1

Box for Salesforce

It’s Dreamforce week!

In honor of one of our most utilized integrations, I thought it would be a great idea to walk through how to set up Box for Salesforce, as well as show how you can make some quick customizations with minimal coding.

Let’s go!

Integration Options

Before diving into the demo, let’s wade through the waters of connecting Box and Salesforce.

Canals of Amsterdam

You have four choices:

Unless your company has a very specific use case, the developer toolkit should solve most requirements, but here is a breakdown of the differences.

The managed package has a fixed folder structure. In the terms of aquatic resemblance, it is like a pond. There’s some water, but not a ton of variance. Permissions in Box match those in Salesforce.

Neighborhood Pond

The developer toolkit allows you to use a list of available methods to customize the managed package to more fit your needs. These methods are automatically available after installing the managed package. I compare this to a river. It is a larger body of water that can meander as needed, even creating impressive natural landscapes like The Grand Canyon. Permissions in Box match those in Salesforce.

Colorado River in The Grand Canyon

The Box SDK for Salesforce uses a different installation than the managed package and serves as a full APEX wrapper, allowing you to complete API calls that the developer toolkit doesn’t allow. This resembles a great lake or sea — lots of water with tons of diverse wildlife and activities. Permissions can be fully customizable.

Chicago and Lake Michigan

The Box REST API lives separate from Salesforce entirely. This should be used when your problem needs a completely custom solution. I liken this to an ocean. You can develop solutions that are deep and wide ranging but requires high skill from experienced professionals.

Zandvoort Beach

To sum everything up, here is a chart that shows the highlights.

Integration Options Matrix

Whew! Now, that we’ve finished our water workout for the day, let’s continue on with the tutorial.

The below walks through an example using the developer toolkit. For more advanced use cases using the SDK or API, stay tuned for more content or reach out to our friends at Box Consulting for a custom engagement.


Enterprise accounts

This probably goes without saying, but just in case, you need to have a Box enterprise account and a Salesforce account with standard user licenses in order to use this feature.

If not, don’t fret! You can sign up for free developer Box and Salesforce accounts at the links provided respectively.

Both give you access to all the features you need to complete this tutorial. You can also do this if you simply wish to follow the tutorial and not make changes to your production environments. Make sure to use a different email address, since you cannot use the same email address in multiple Box instances. I won’t go over the sign up process here, since it is pretty self explanatory. Tip — I recommend using the developer accounts option if you are new to all of this.

Set up users

Once you have the enterprise accounts setup, confirm the following user accounts exist in Box and Salesforce.

  • Salesforce admin account — If you went through the developer account sign up process above, this is the login you created as part of that. If not, you will need Salesforce administrator login credentials.
  • Salesforce user account — This can be any user in your Salesforce instance, including your Salesforce admin. It will get connected to whatever Box user you login to the Box widget with later in the tutorial.
  • Box service account — It is advised to create a managed user in Box to own all content created from the Salesforce integration, as well as make all API calls with. You can use the Box primary admin account, but it is not recommended to do so.
  • Box user account — This account must be different than the above Box service account. For this tutorial, I’m going to use the Box admin account as the user account. This is the Box account that will get tied to your Salesforce user account upon login to the Box widget.

Install Visual Studio Code

We will be using an extension to deploy our code later. In order to do this, you will want to go ahead and have Visual Studio Code installed. Find the install and instructions here.

After the install is complete, open the program and Install the Salesforce Extensions.

Install Salesforce Extensions

Install Box for Salesforce

  1. Click the green Get It Now button on the Box for Salesforce app exchange page. If you are not already logged in, it will prompt you to login with a account. If you don’t have one already, just go through the signup flow using your Salesforce admin accounts credentials.
Box for Salesforce App Exchange page

2. For the purposes of this demo, I’m going to select install in production, but if you are not using the developer account option, you could select install in sandbox.

Install location selection

3. Accept the terms and conditions and click Confirm and Install.

Install confirmation

4. If you are not already logged in. you will be redirected to Salesforce to login with the Salesforce admin account credentials.

5. When you reach this screen, make sure Install for Admins Only is selected and click Install.

NOTE — in order to give access to the Box application to other Salesforce users, you will need to apply permissions sets. You can find information on that process here. I’m not going to go over that in this blog post, since it is not needed for the tutorial.

Install for admins screen

6. Check the box and click Continue. This allows Salesforce to talk to Box on the backend.

Approve third party access screen

7. The installer will run. It takes a few minutes to complete.

Installing screen

You might receive this message. If so, click Done and wait for the email to say the install is complete.

Install taking longer screen

8. Once the install is complete, you should see the package in your installed packages section of setup.

Install complete

That completes the installation. Onward to configuration!

Thames River, Big Ben, and Westminster

Configuring Box for Salesforce

  1. From the app launcher, click View All.
App launcher

2. Click Box.

Select Box

3. Click the Box Settings tab.

Box settings screen

4. Select Authentication, and then click Connect. Make sure you aren’t already logged into Box in another tab. We want use the Box service account you set up earlier.

Authentication screen

5. Log in to Box using the service account’s credentials. Then, click Grant access to box. If successful, you will be redirected back to the authentication screen.

Grant access to Box

6. In the Content Settings section of Box settings, type a folder name for all of your company’s Salesforce content to live in. Then, click Save. This will create a folder in Box in the Box service account’s root folder.

Content settings screen
Salesforce content folder

While on the Content Settings screen, you will also want to set you Box Enterprise Sub-Domain — if you have one. You can find that by going to the Box admin console > Enterprise Settings > Custom Setup > Company Profile.

Box Custom Domain

Copy the subdomain and paste it into the text box in the Content Settings subdomain field. Click Save.

Add subdomain to Box configuration

7. In the Box User Settings section of Box settings, click Connect Account. Then, login to Box using the Box user account from earlier. I’m also going to enable Auto-Collab and seamless login for a better user experience.

At this point, the integration is set-up enough for us to move onto coding some custom experiences; however, there are lots of other administration settings and options you can choose for your organization. While I won’t go over them here, you can visit our admin guide to read through those choices. Let’s get coding!

The River IJ

Box for Salesforce Developer Toolkit

Out of the box, the managed package will organize content like the below with each object having its own folder.

Default content hierarchy

But what if we wanted to place all content for a sales prospect under one folder? Let’s walk through how to do that.

Custom content hierarchy

Embed Box component in the Accounts page

  1. In order for users to be able to use Box within Salesforce, we need to add the Box component to the accounts page. Make sure you are logged in with your Salesforce admin account, and visit an account page. Click the gear in the top right, followed by Edit Page.
Account screen

2. For this example, I’m going to add a Box tab to the middle. Click on the box. Then, click Add Tab.

Add tab

3. Select Custom in the tab label dropdown. Then, type Box in label text box.

Add Box label

4. In the left components selection section, scroll down and find Box. Click the Box tab in the middle section and drag the component to the place that says “Add Component(s) Here.”

Insert Box component

5. Click Save in the top right.

Save changes

6. Click Activate. Now, a Box tab will appear for anyone who looks at an account page. After clicking activate, you will see a pop up asking if you want to make this an org-wide default.


Activate changes

7. When a user visits a record that hasn’t had a Box folder created yet, they will see the below. Clicking Create Folder will make the Box folder for this account.

Create folder screen
Folder created in Box

If a folder has been created already, the user will see the below.

Reminder — If a Salesforce user has access to the account in Salesforce, the Box user connected to it will also have access to the folder from the Box webapp.

Folder created in Salesforce

Create a custom folder hierarchy

The standard managed package can be setup like above on both standard and custom objects in Salesforce, but like I showed earlier, we can easily customize the folder structure using a tiny bit of APEX code.

For this example, I’m going to show how to create the opportunity folder under the account folder, but this demo can be extended to any number of objects — custom or standard.

Custom content hierarchy

Behind the scenes, Box uses something called the FRUP table to maintain the integration. You can find out what is in the FRUP table by running a report, as shown in the instructions here.

For this example we are going to create an APEX trigger that causes an APEX class to run after a record is inserted into the FRUP table — in our case when an opportunity folder is created. When the class runs, it will move the opportunity folder created under the account folder that opportunity is connected to.

Like I mentioned in the pre-requisites, we are going to use the Visual Studio Code Salesforce Extensions to write and deploy our APEX code.

  1. As part of that, we will use the Salesforce CLI. So, the first step is to install it. Find the installer for your OS here.
Salesforce CLI

2. Confirm the install is complete by running sfdx --version in a terminal or command prompt. You will see the Salesforce CLI version returned.

Salesforce CLI version

3. To access the code snippets we are going to deploy, visit the GitHub page for our Salesforce Examples. You may clone the repository or download a zip. Then, in Visual Studio Code, open up the box-salesforce-demo-101 folder. Note — this is one folder below the root.

Open box-salesforce-demo-101 folder

4. Open the command palette (view > command palette or use the keyboard shortcut) and type SFDX: Authorize an org. Hit Enter.

Open command palette

5. Accept the project default. Hit enter.

Project selection

6. Enter an org alias if you have one. For this example, I don’t, so I’m going to leave it blank. Hit enter.

Org selection

7. Login to Salesforce using your Salesforce admin account.

Salesforce login screen

8. Allow Access by clicking Allow.

Click allow

9. If successful, you will see the below pop-up in Visual Studio Code.

Authorization successful

10. For this tutorial, you won’t need to make any code changes, but if you want to see the code being deployed, view it below.

RecordFolderHandler class
FrupTrigger trigger

11. To deploy the code, open a terminal in Visual Studio Code (Terminal > new terminal or use the keyboard shortcut). Type sfdx force:source:deploy -m ApexClass,ApexTrigger and hit enter.

Run deploy command

If successful, you will see the below pop-up message.

SFDX deploy successful

And just like that! — when you create a folder on an opportunity record, it will move that folder under the account for that opportunity.

It may take Salesforce several seconds to auto refresh the Box component. If you want to see results immediately, refresh your page manually

Opportunity folder under the account folder

What a journey! I hope you enjoyed this high level overview of getting started with Box for Salesforce development. This is just the tip of the iceberg in terms of what you can do using the integration.

In part two, we will look at editing the two example snippets, as well as go over another common use case: removing the need for a user to click the “Create Folder” button. Stay tuned.

Happy Coding!

Colorado River Austin, TX

Additional Resources

List of Box for Salesforce Developer Toolkit Methods

Admin configuration guide

Box Sign integration guide

APEX code samples


…And as always, feel free to post questions on our developer forum.

Special thanks to Kyle Adams, nicholas read, and Randy Johnston!

Niagara Falls



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alex Novotny

Alex Novotny

I’m a Box Developer Advocate, helping others learn how to maximize their investment through Box Platform.