ExperienceCloudToolkit class provides global methods for managing Box App Users within Salesforce Experience Cloud environments. These methods support creating, deactivating, and looking up Box App Users linked to Salesforce users.
Methods
createAppUserforCurrentUser()
Creates a Box App User for the currently logged-in Salesforce user.
Signature:
Global static BoxUser.Info createAppUserforCurrentUser()
Returns:
BoxUser.Info. Information about the created or existing Box App User.
createAppUserforUser() using the current user’s ID. If an active App User already exists for the user, it returns the existing user’s information.
Example:
createAppUserforUser(String userId)
Creates or reactivates a Box App User for a specific Salesforce user.
Signature:
Global static BoxUser.Info createAppUserforUser(String userId)
Parameters:
Returns:
BoxUser.Info. Information about the created or existing Box App User.
-
It searches for an existing Box App User where the
external_app_user_idmatches the SalesforceuserId. - If an active user is found, it returns that user’s information.
- If an inactive user is found, it reactivates the user and returns its information.
-
If no user is found, it creates a new App User with the following properties:
-
name: The Salesforce user’s name -
external_app_user_id: The SalesforceuserId -
is_platform_access_only:true -
status:active
-
deactivateCurrentUserAccount()
Deactivates the Box App User account for the current Salesforce user.
Signature:
Global static Boolean deactivateCurrentUserAccount()
Returns:
Boolean. Istrueif deactivation was successful,falseotherwise.
deactivateUserAccount() using the current user’s ID to set their Box App User status to inactive.
Example:
deactivateUserAccount(String boxUserId)
Deactivates a specific Box App User account.
Signature:
Global static Boolean deactivateUserAccount(String boxUserId)
Parameters:
Returns:
Boolean. Istrueif the deactivation is successful (HTTP 200 OK), andfalseotherwise.
inactive. This prevents the user from accessing Box content but does not delete their account.
Example:
searchForExistingUser(String externalAppUserId)
Searches for a Box App User by their external ID.
Signature:
Global static BoxUser.Info searchForExistingUser(String externalAppUserId)
Parameters:
Returns:
BoxUser.Info. Information about the found Box App User.
ExperienceCloudToolkitExceptionif no user is found with the specified external ID.
external_app_user_id matches the provided value. This is useful for checking if a Salesforce user already has an associated Box App User.
Example:
Exceptions
ExperienceCloudToolkitException
A custom exception thrown for failed operations, such as when a user is not found by searchForExistingUser().
Notes
- All methods authenticate with the Box API using the Service Account token.
-
Created App Users are “platform-only” (
is_platform_access_only = true), meaning they can only access Box through the application. -
The
external_app_user_idfield links Box App Users to Salesforce User IDs. -
API versioning is managed through the
SettingUtils.getAPISetting('ExperienceCloudToolkit')configuration.
