Reference information for the UI extensions SDK, which provides utilities for app cards.
hubspot.extend()
inside the component file instead of exporting it. This is not required when you create a sub-component. For cleaner code, reuse and include them inside your extension.
The hubspot.extend()
function receives the following arguments:
context
: provides account, extension, and user context to the extension.actions
: makes actions available to the extension.hubspot.extend()
or the extension component.
context
object, passed to the extension component via hubspot.extend()
, contains data related to the authenticated user and HubSpot account, along with data about where the extension was loaded. It has the following fields:
Field | Type | Description |
---|---|---|
location | 'crm.record.tab' | 'crm.record.sidebar' | crm.preview | helpdesk.sidebar | The UI extension’s location. |
crm.objectId | Number | The ID of the CRM record (e.g., contact ID). |
crm.objectTypeId | String | The ID of the CRM record’s object type (e.g., 0-1 ). See the full list of object IDs for reference. |
extension.appId | Number | The extension’s app ID. |
extension.appName | String | The name of the extension’s app. |
extension.cardTitle | String | The extension’s title. |
portal.id | Number | The ID of the HubSpot account. |
portal.timezone | String | The account’s timezone. |
portal.dataHostingLocation | 'na1' | 'na2' | 'na3' | 'ap1' | 'eu1' | Geographic identifier that denotes the region where the current portal is hosted. See HubSpot Cloud Infrastructure FAQ for more details. |
teams | Array | An array containing information about teams that the user is assigned to. Each team object contains the id and name of the team, along with a teammates array that lists the IDs of other users on the team. |
user.email | String | The user’s email address. |
user.emails | String[] | All of the user’s associated email addresses. |
user.firstName | String | The user’s first name. |
user.id | Number | The user’s ID. |
user.locale | String | The user’s locale. |
addAlert
method to send alert banners as a feedback for any actions to indicate success or failure. addAlert
is a part of the actions
object that can be passed to extension via hubspot.extend
. If you instead want to render an alert within a card, check out the Alert component.
addAlert
action is passed into hubspot.extend()
and the Extension
component, then is triggered when the hubspot.fetch()
function successfully executes.
Prop | Type | Description |
---|---|---|
title | String | The bolded text of the alert. |
message | String | The main alert text. |
variant | 'info' (default) | 'tip' | 'success' | 'warning' | 'danger' | The color of the alert.
|
fetchCrmObjectProperties
, which can be included in your React files to fetch property data client side at extension load time. This method is described below.propertiesToSend
, which can be included in your hubspot.fetch()
functions to fetch property data on the back-end at function invocation time./collector/graphql
endpoint. Learn more about querying CRM data using GraphQL.fetchCrmObjectProperties
method, you can get property values from the currently displaying CRM record without having to use HubSpot’s APIs. This method is a part of the actions
object that can be passed to the extension via hubspot.extend
. You’ll first need to add the object to objectTypes
inside the card’s .json
config file. The objects you specify in objectTypes
will also set which CRM objects will display the extension.
fetchCrmObjectProperties
is formatted as:
refreshObjectProperties
to refresh the property data on the CRM record, and any CRM data components on the record without needing to refresh the page. This includes cards added to the record through HubSpot’s UI. This method will work for the CRM objects that you include in the extension’s .json
file in the objectTypes
array.
onCrmPropertiesUpdate
to subscribe to changes made to properties on the CRM record and run hubspot.fetch()
functions based on those changes. This only includes changes made from within the HubSpot UI, not property updates from outside the UI, such as via APIs. This action is intended to be used like a React hook.
The full API for this method is as follows:
error
argument to the callback.
Modal
: a pop-up dialog box best suited for short messages and action confirmations. A 'danger'
variant is included for destructive actions, such as deleting a contact.Panel
: a slide-out sidebar best suited for longer, compartmentalized tasks that users might need to perform, such as multi-step forms. Includes a 'modal'
variant to obscure page content outside of the panel to focus the user on the panel task.overlay
prop to a Button, LoadingButton, Link, Tag, or Image component.Modal
or Panel
component into the overlay
prop.Button
, LoadingButton
, Link
, Tag
, or Image
component within overlay
that triggers the closeOverlay
action in an onClick
event. To use this action, you’ll need to include the actions
argument in hubspot.extend()
.
Below are examples of a panel overlay and a modal overlay.
addAlert
and fetchCrmObjectProperties
, you can pass openIframeModal
to the extension through the actions
object. This action includes a callback, which you can use to run a function when the iframe modal is closed. The callback doesn’t receive any parameters.
openIframeModal
takes the following payload:
copyTextToClipboard
action to copy text to your clipboard. This action can be accessed through the actions argument (actions.copyTextToClipboard
) and returns a promise that resolves once the system clipboard has been updated. Its functionality is provided by the Clipboard: writeText() method and follows the same requirements.
This action only works after the user has interacted with the page after loading (transient activation).
logger
methods, you can send custom log messages to HubSpot for more in-depth troubleshooting of deployed extensions. Custom log messages will appear in the app’s logs in HubSpot.
The following methods are available:
logger.info
logger.debug
logger.warn
logger.error