APIs & Integrations

MindfulMike
Participant

Unsanitize action hook message toast

How can I un-sanitize a toast message?  
I made a “Copy Deal” action button that createds a copy of the current deal when clicked.  The cloud function returns :  {status: ‘success’, message: ‘Deal <a href=‘[dealUrl]‘>ABC12</a>’ created.}  HubSpot shows the message in a green toast but it doesn’t show the link, instead it sanitizes it, I assume, and the user sees the literal HTML code instead of a nice link.  How can I tell HubSpot to not sanitize the link?

(I have the workaround - a nice modal with the link but my client wants everything "within the HubSpot UI").

Thanks in advance.

0 Upvotes
5 Replies 5
MindfulMike
Participant

Unsanitize action hook message toast

Update: Support says this is not possible.  You must use an iframe action to show HTML.

0 Upvotes
MindfulMike
Participant

Unsanitize action hook message toast

More succintly:

res.json({"message": "<a href='https://app.hubspot.com/contacts/1234567/deal/7654321'>Deal Awesome Deal 1</a> has been created."})

shows:
Deal <a href='https://app.hubspot.com/contacts/1234567/deal/7654321'>Awesome Deal 1</a> has been created. 
not the expected (where "Awesome Deal 1" is a link):

Deal Awesome Deal 1 has been created.

0 Upvotes
MindfulMike
Participant

Unsanitize action hook message toast

Note that the formatting of the post above shows a link but the toast message does not, just the text.

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

Unsanitize action hook message toast

Hey @MindfulMike ,

Could you provide a code snippet?   I am gathering that you are working with the CRM Extensions API but wanted to confirm that as well

Adding @himanshurauthan and @jpsanchez to the thread for  their expertise as well 😃

0 Upvotes
MindfulMike
Participant

Unsanitize action hook message toast

Here's some Typescript that runs on Node for ya....

static dealAnchor(deal:Deal, portalId: number😞 string {
return "Deal <a href='"+Deal.url(deal, portalId) +"'>" + deal.properties.dealname + "</a>";
}

 

const newDealCopyResult = await hsRest.copyDeal(dealId, Number.parseInt(req.params.userId))
res.json({"message": Deal.dealAnchor(newDealCopyResult.deal, portalId) + " has been created. "
+ newDealCopyResult.warnings});

 The user then sees:
Deal <a href='https://app.hubspot.com/contacts/<...portal...>/deal/<...deal...>'>Awesome Deal - Copy</a> has been created.
The expectation is that the user sees this, where the stuff in quotes is an HTML anchor (a link):
Deal "Awesome Deal - Copy" has been created.

0 Upvotes