Convert HTML to PDF Custom Button
Introduction
In FieldFX, you can add the ability to convert a HTML file to PDF on request in Back Office. The HTML file will be converted to PDF on save (or on sync if created in Mobile).
You can define the PDF file name when the report is converted and also define which SObject(s) to perform the conversion. The conversion can be on a job and ticket, but not on a quote.
FieldFX sends out an error e-mail if the conversion is not successfully.
You can trigger the conversion manually, if the automation fails. You can save the generated PDF documents under Files.
You also can delete the original HTML file get deleted once the equivalent PDF is created.
You must upgrade your FieldFX Managed Package to v1.509 and FieldFX Lightning Managed Package to v1.209 before you add the button. |
Step-by-Step Guides
These step by step guides detail the setup and use of the Convert HTML to PDF button.
These steps detail how to setup the button for a Job. To use the button on Tickets and Quotes, you must repeat the setup steps for the Ticket and Quote object. |
Setup Tasks | Use Tasks |
---|---|
The task steps are the same except for the object used. |
Setup the HTML to PDF button
Repeat these steps to add the same button to a ticket or a quote.
Create Action Button in FX Back Office
-
Log into FieldFX Back Office.
-
From Setup, enter object in the Quick Find box.
-
Select Object Manager and then
For a Job: For a Quote: For a Ticket: Select the Job object.
Select the Quote object.
Select the Ticket object.
-
Select Buttons, Links, and Actions from the menu.
-
Click New Action.
This action must be added to the Job, Quote, and Ticket objects. -
At the New Action screen, complete the following:
Field Action Action Type
Select Lightning Web Components.
Lightning Web Component
Select
FX5:convertHTMLToPDF
.Standard Label Type
Leave at
--None--
.Label
Enter
HTML to PDF
Name
When you click on this field, it’s automatically populated by what you entered in the Label field. The spaces are replaced with underscores.
Description
(Optional)You can enter a short description of the button’s description.
-
Click Save.
-
Continue with Add to Page Layout section.
Add to Page Layouts
-
While still in the Job, Quote, or Ticket object, select Page Layouts.
-
Select the object:
-
For a Job: Job Layout.
-
For a Quote: Quote
-
For a Ticket: Ticket
-
-
Click Mobile & Lightning Actions.
-
Find the new HTML to PDF action that you created.
-
Drag HTML to PDF and drop it into the Salesforce Mobile and Lightning Experience Actions block under Job Detail.
If you don’t see the list of actions but see this message, this section is predefined by Salesforce.
Click the …override the predefined actions… link to expose those actions and add the custom action.
-
Only three buttons appear on the Job record. You can access the HTML to PDF button by selecting the down arrow and scrolling down the menu to HTML to PDF
-
If you want the new button to appear on the Job Record, drag the button to the first position in the Salesforce Mobile and Lightning Experience Actions block on the Job page layout
-
-
To save the changes, click Save.
The layout is saved and the list of page layouts reappears. -
Continue with Add the URL to Remote Settings.
Add the URL to Remote Settings
For more information, see Add Remote Site Settings for Lightning Components.
If you have already added the Remote Site URL for another object, you won’t have to add it again. It already exists in your org. |
-
While still in Setup, use the Quick Find box and type
remote
. -
Select Remote Site Settings.
-
Click New Remote Site.
-
At the Remote Site Edit, complete the following:
Field Action Remote Site Name
Enter the name for the site, such as Convert_HTML_to_PDF.
The Remote Site Setting API Name can only contain underscores and alphanumeric characters. The name must:
-
Begin with a letter
-
Not include spaces
-
Not end with an underscore
-
Not contain 2 consecutive underscores
Remote Site URL
Enter the custom URL.
See Add Remote Site Settings for Lightning Components on how to add a remote site custom URL.
Disable Protocol
Security checkboxSelect this checkbox to allow s-controls to access this remote site regardless of HTTP or HTTPS session security. Only select this checkbox if you understand the security implications.
Description
(Optional)You can enter a brief description for the URL.
Active checkbox
Leave selected.
-
-
Click Save.
-
Continue with Add New AppSetting Fields section.
Add New AppSetting Fields
With the button defined and on the page layout, you need to set up these AppSettings:
These AppSettings have been added as part of FieldFX Managed Package v1.509 and should exist in your org upon upgrade. |
Required |
|
-
From Setup, enter
Custom Metadata
in the Quick Find box. -
Select Custom Metadata Types.
-
In the AppSetting row, click Manage Records.
-
In the AppSettings window, click New.
-
Complete these AppSettings:
Field Convert to PDF Failure Notification Email Delete HTML Original Label
(Required)Automatically Convert to PDF
FailureNotificationEmail
Delete HTML Original
App Setting Name
(Required)Protect Component checkbox
Leave unchecked.
Active checkbox
Leave unchecked.
Value
(Required)Set to false.
-
Click Save & New.
Use Convert HTML to PDF
With the Convert HTML to PDF button available, you can convert HTML files to a PDF and attach it to a job, ticket, or quote.
-
In your org, click:
Use this tab… For … Jobs
Jobs
Quote
Quote
Ticket
Ticket
-
Select a listed job, quote, or ticket.
-
Click HTML to PDF.
-
At the HTMLToPDF modal,
-
If you want to delete the original HTML file, click the Delete Original toggle off.
-
By default, the HTML file is also saved with the PDF file.
-
Click Convert HTML Reports. If successful, Success appears at the bottom of the modal.
-
-
Close the HTML to PDF modal.
-
Refresh the page.
The PDF also appears in the Notes & Attachments block on the Related tab.