Skip to main content
Question

Box UI Elements in Salesforce community

  • May 22, 2025
  • 2 replies
  • 30 views

Forum|alt.badge.img

Just wondering if anyone managed to get Box UI Elements (Content Explorer and Content Uploader) working in a community.

 

Below is a snippet of a Visualforce page:

<apex:page standardController="Registration__c" extensions="Registration_Box_Ext" standardStylesheets="false">
<apex:includeScript value="{! $Resource.polyfill }" />

<div class="container">div>
<script>
var contentExplorer = new Box.ContentExplorer();
var accessToken = "{!accesstoken}";
console.log('Access Token: ' + accessToken);
var folderid = "{!Registration__c.BoxFolderId__c }";
console.log('Folder ID: ' + folderid);
contentExplorer.show(folderid, accessToken, {
container: ".container"
});
</script>
apex:page>
 
Extension:
public with sharing class Registration_Box_Ext {

private final Registration__c rego;

public Registration_Box_Ext(ApexPages.StandardController stdController) {
this.rego = (Registration__c)stdController.getRecord();
}

public String getAccessToken() {
String enterpriseId = '';
String publicKeyId = '';
String privateKey = '';
String clientId = '';
String clientSecret = '';

BoxJwtEncryptionPreferences preferences = new BoxJwtEncryptionPreferences();
preferences.setPublicKeyId(publicKeyId);
preferences.setPrivateKey(privateKey);
BoxPlatformApiConnection api = BoxPlatformApiConnection.getAppEnterpriseConnection(enterpriseId, clientId, clientSecret, preferences);
return api.accessToken;
}

}

2 replies

Forum|alt.badge.img

Hi ,

 

What types of issues / errors are you seeing when you're trying to integrate?

 

- Jon


Forum|alt.badge.img

Hi  ,

 

Thanks for your response.

 

I found out that the error is a permission error. I create the folder using the Salesforce service account, but then I am using a JWT app user to generate the token and passing this to the UI Element Javascript.

 

I'm not sure where to go from here. The idea is that I need to allow non Box users to see and upload to a certain sub folder of a Salesforce record folder. Hence the use of the UI Element library.

 

I'm guessing one solution could be to add the Custom App user to the folder, but I don't know how to know what that folder is.

Or is it possible to someone use the Custom App to create a token for the Salesforce service account user?