formatCrmProperties utility that applies HubSpot’s standard display formatting to CRM property values. This helps keep your extension consistent with HubSpot’s UI, and is particularly useful when you get raw property values from:
- The
fetchCrmObjectPropertiesaction hubspot.fetch()or serverless function requests
Usage
formatCrmProperties accepts raw property values and returns them with HubSpot’s standard display formatting applied. By default, it formats recognized property types. For example, it formats phone numbers and numeric values, and resolves enumeration values to their display labels. You can optionally use the formattingOptions prop to customize how dates, datetimes, and currencies display.
The function accepts either a single property map or an array of property maps, and returns the same shape it receives.
Parameters
Formatting options
TheformatCrmProperties function applies HubSpot’s standard display formatting to recognized property types even without formattingOptions. However, you can use the formattingOptions prop to customize how date, datetime, and currency properties display.
Below are the available options for the formattingOptions parameter.
The following example applies currency, date, and datetime formatting to a deal’s properties:
Return value
The function returns aPromise that resolves to:
- A single
Record<string, string | null>whenpropertiesis a single object. - An
Array<Record<string, string | null>>whenpropertiesis an array.
null in the input are preserved as null in the output.
The function handles the following edge cases:
- If you pass an unknown property name, the function will return its value unchanged.
- If you pass an empty array, the function will return
[]. - If you pass an invalid
objectType, the promise will reject.