Data & connectors
Add a Salesforce PDF button
With a Weft button on a Salesforce record page, a rep clicks the button on an opportunity and gets that opportunity's quote as a PDF, filled from the record. The button renders the 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 Salesforce connection must exist — see Connect Salesforce — and 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 clicks the button needs a Weft account in the same workspace with the editor role or higher. A viewer's click is refused.
Prepare the template
- In the template's data source, filter on the record ID as a parameter — Weft's own example is
Id equals
:recordId, with a limit of 1. A click fills:recordIdwith the record's ID. - Publish the template: open the Save ▾ menu — the caret beside Save, whose tooltip reads Save options — and choose Publish. See Publish a template.
Publish again after every change you want the button to show.
Copy the button link
- Open the data pill — the button in the bar directly above your document that names the data you are previewing — and choose Manage sources…. The Data sources window opens for this template.
- Below the list, under Generate from Salesforce, press Copy URL. It briefly reads Copied!.
Generate from Salesforce appears once the template has a data source. The link names the template and the workspace you are signed in to.
Add the button in Salesforce
Weft's instructions, shown with the link:
- Create a Salesforce URL button, or a quick action, that opens this template for the current record.
- Set the button's content source to URL, and paste the link.
- Check the record-ID merge field inside the link.
{!Record.Id}stands for the record's ID; adjust it for your object if needed, for example{!Opportunity.Id}.
Choose whose Salesforce access it uses
The Data sources window also has a checkbox, Each user connects their own Salesforce.
Each user connects their own (the default)
Each click reads Salesforce as the person clicking, under their own sharing rules and field permissions. The first time, Weft shows Connect Salesforce to continue; they press Connect Salesforce, approve Salesforce's consent screen in the new tab, and Weft then generates the document. They only do this once.
Shared access (admin)
Unticking the box makes every click read Salesforce through the access of the person who set up the connection. Clickers need no Salesforce login of their own and see what that person can see, which is why only an admin can turn it on.
Unticking opens Turn on shared access?, which lists every data query of the version the button renders, in full. Turn on approves exactly those queries.
- While it is on, only an admin can add or change the template's data sources; others see View instead of Edit.
- When you publish a version whose query differs from the approved one, the button is refused until an admin approves it: the window says so, and an admin presses Review and approve, then Approve. A version with the same queries stays approved.
- Anyone with the editor role or higher can tick the box again (Turn off). Only an admin can turn it back on.
Previews and exports in the editor always use the editor's own login.
What people see when they click
A Weft sign-in screen if they are not signed in, then Signing you in… and Generating your document…. The PDF fills the page under a header showing the template's name, its page count and Download PDF. The downloaded file is named by the template's File name setting, or after the template and the date. If saving to the record is turned on, the header also shows Save to Salesforce — see Save a PDF to the Salesforce record.
If the button fails
| What the person sees | Usually means | What to do |
|---|---|---|
| This document link is incomplete | The link arrived without a template or a record ID | Copy the link from Weft again |
| We couldn't sign you in | Weft could not confirm the person's sign-in | Press Try again |
| You don't have access | The account is not a member of the workspace in the link | Sign in with a member account, or ask an admin for an invite |
| Connect Salesforce to continue | Per-user access, not connected yet | Press Connect Salesforce; allow pop-ups if asked |
| We couldn't generate this document | The render was refused; the reason is shown | Fix the cause, then Try again |
Common reasons under We couldn't generate this document:
- "That template no longer exists, or you don't have access to it." It was deleted — restore it, see Manage templates — or belongs to another workspace.
- Shared access is on, but an admin has not approved the version the Salesforce button renders. An admin approves it in the Data sources window.
- Shared access is on, but the version the button renders has no data source of its own. Publish the template again, then have an admin approve that version.
- "this connection has not been authorized yet — ask an admin to connect it". Shared access is on, but the connection's owner has not connected their own login.
- A permission refusal: the account has the viewer role and needs editor or higher.
Good to know
- One data source. If the template has several, the button uses the one created first.
- Never published? The button renders the latest saved version until the first publish.
- Publish after a data-source change. The button runs the query saved with the version it renders, until you publish again. A data-source change marks the document Unsaved, like any other edit, so save it (⌘S, or Ctrl+S on Windows) and publish the new version — see Publish a template.