All articles

Data & connectors

Generate a PDF from a HubSpot record

With the Weft panel on a HubSpot record page, a rep presses Generate PDF on a deal and gets that deal's document as a PDF, filled from the record. Weft offers the templates that fit the record, and renders a template's published version, not whatever is being edited at the moment.

Before you start

  • This works in the hosted app only (signed in to a workspace).
  • A HubSpot connection must exist — see Connect HubSpot. The panel comes with Weft's HubSpot app, so there is nothing extra to install.
  • The template needs a data source that reads the record — see Build a data source.
  • Setting up the data source and publishing need the editor role or higher; turning on shared access (below) needs the admin role or higher.
  • Everyone who presses Generate PDF needs a Weft account in the same workspace with the editor role or higher. A viewer is refused.
  • Adding the panel in HubSpot needs a HubSpot user who may customize record pages.

Prepare the template

  1. Give the template a data source on your HubSpot connection that reads Deals, Contacts, Companies or one of your custom objects. Custom objects come with paid HubSpot plans; they appear in the object list by their name (for example Projects) when your HubSpot login lets Weft read them.
  2. Add a filter on hs_object_id equals :recordId. HubSpot's record ID is listed in the field list under that name, hs_object_id. Pressing Generate PDF fills :recordId with the record's ID.
  3. Publish the template: open the Save ▾ menu — the caret beside Save, whose tooltip reads Save options — and choose Publish. See Publish a template.

In the template's Data sources window, Generate from HubSpot says when the panel won't offer the template: its first data source doesn't filter on :recordId, or reads an object the panel isn't on.

Add the panel in HubSpot

Do this once for each kind of record — deals, contacts, companies, each custom object — whose page should have the panel:

  1. Open a record of that kind in HubSpot and press Customize.
  2. Under Record customization, open Default view.
  3. Press Add card (+). In the dialog, choose App cards, then add Weft Docs.
  4. Close the dialog, then press Save and exit.

What people see

The panel reads "Turn this deal into a PDF with one of your Weft templates" (on a custom object's page, "Turn this record into a PDF…"), with a Generate PDF button, unless a HubSpot admin changed the wording (see Change what the panel says). Pressing it opens Weft in a new browser tab, so the HubSpot record stays open: a sign-in screen if they are not signed in, then Signing you in… and Finding your documents….

  • One template fits the record: Generating your document…, then the PDF under a header showing the template's name, its page count and Download PDF.
  • Several fit: Choose a document lists them by name; pressing one generates it.
  • None fits: Weft says what to set up (see If it fails).

Next to Download PDF, the header can also show Save to HubSpot, which saves the PDF onto the record as a private file on a note — only when the person presses it. See Save a PDF to the HubSpot record.

Change what the panel says

A HubSpot admin can replace the button's label and the line above it, separately for deals, contacts, companies and custom objects (one wording for every custom object):

  1. In HubSpot, open the Marketplace icon, then Connected apps.
  2. On the My apps tab, open Weft Docs, then its Settings tab.
  3. Under each kind of record, type the wording in Button label and Caption. A box left empty keeps Weft's own wording, shown in grey.
  4. Press Save. Record pages show the new wording the next time they open.

To go back to Weft's own wording everywhere, press Clear every box, then Save.

A button label can be up to 40 characters and a caption up to 300, each one line of plain text. The wording applies to the whole HubSpot account, whichever Weft workspace people generate from. If Weft can't be reached when a record page opens, the panel shows Weft's own wording.

Someone who belongs to more than one Weft workspace goes into the one they last chose in Weft. If they never chose one, Weft asks Choose a workspace once and remembers the answer.

Choose whose HubSpot access it uses

The template's Data sources window has a checkbox, Each user connects their own HubSpot.

  • Each user connects their own (the default). Each press reads HubSpot as the person pressing, with their own HubSpot permissions. The first time, Weft shows Connect HubSpot to continue; they press Connect HubSpot, approve HubSpot's consent screen, and Weft then generates the document. They only do this once.
  • Shared access (admin). Unticking the box makes every press read HubSpot through the access of the person who set up the connection, so people need no HubSpot login of their own. Only an admin can turn it on, and doing so approves the exact data queries of the version the panel renders — the same rules as Add a Salesforce PDF button describes for Salesforce.

Previews and exports in the editor always use the editor's own login.

If it fails

What the person seesUsually meansWhat to do
No template is set up for HubSpot deals yetNo template's first data source reads that object and filters on :recordIdPrepare a template as above, publish it, then press Check again
HubSpot isn't connected in this workspaceThe workspace has no HubSpot connectionAn admin adds one — see Connect HubSpot
Weft can't find this kind of HubSpot record (on a custom object's page)None of the workspace's HubSpot connections shows this custom object to the person's HubSpot loginReconnect HubSpot in Weft under Settings → Integrations. If the object was just created again in HubSpot, wait a minute, then press Check again
"Weft needs your own HubSpot login to tell which kind of record this is"On a custom object's page whose data source Weft couldn't match, Weft looks the object up with the person's own HubSpot login, which they haven't connected yetConnect HubSpot in Weft under Settings → Integrations, then press Try again — or have an editor open the template's data source and save it again
We couldn't find your documentsWeft could not read the workspace's templates; the reason is shownPress Try again
You don't have accessThe account is not a member of a Weft workspaceSign in with a member account, or ask an admin for an invite
Connect HubSpot to continuePer-user access, not connected yetPress Connect HubSpot; allow pop-ups if asked
We couldn't generate this documentThe render was refused; the reason is shownFix the cause, then Try again

Good to know

  • One data source per template. The panel looks at, and renders, the data source created first.
  • One workspace at a time. The panel lists templates from the Weft workspace the person is in.
  • More than one HubSpot connection? The panel can list a template built on a different HubSpot account; that template then can't find the record. Keep one HubSpot connection per HubSpot account a team works in.
  • Never published? The panel renders the latest saved version until the first publish.
  • Deals, contacts, companies and custom objects. Tickets and other HubSpot objects don't have the panel.
  • Custom objects and shared access. On a custom object's page, Weft recognises the custom object from what it noted when the data source was saved, so shared access works without a HubSpot login of the person's own. If the custom object was deleted and created again in HubSpot since then, Weft asks HubSpot with the person's own login until an editor saves the data source again.

What next