Custom CRM Card - Print Specific Elements

I’m fairly certain this is the wrong forum for this question, but I didn’t see a specific crm/dev forum. If there is one and I’m just missing it, please point me in the right direction!

I’m working on a custom card that fetches and displays CRM contact properties, as well as several other HTML components that make up a form (not being submitted, for display/print purposes only), and a ‘print’ button.

The issue I’m running into is that react can’t use window.print, so I’m attempting to incorporate react-to-print via npm. I am just getting started with react-to-print, but while the build completes and uploads, the card breaks when adding this functionality, and I’m expecting a lot of troubleshooting.

My question is, has anyone built a card with print functionality using react-to-print? Just looking for info on if this approach will work, if HS has limitations here, or if anyone has gone a different route and been successful. I sincerely appreciate any help!

Hi, @MIsbrecht :waving_hand: I come offering questions.

  • Have you thought about trying to open the content in a new window or iframe and invoking the window.print() from there?
  • Basic, but, have you checked the browser console for any error messages?
  • Have you set up any error handling in your code?

Thanks for the additional information! — Jaycee

Hi Jaycee,

Yes, after discussing in the developer slack and digging in further on the limitations on the custom cards the iframe route looks to be the only direction to go in. I really appreciate your response!

Matt

Thank YOU, @MIsbrecht! — Jaycee