---
title: "Work Order PDF [OLD]"
canonical: "https://help.fieldbuddy.com/space/FBDOCS/5357928449/Work%20Order%20PDF%20%5BOLD%5D"
format: markdown
---
> Macro (toc)


# Description

### What is Work Order PDF

Work Order PDF is a functionality that generates an overview of the Work Order in PDF.

This feature allows to configure and send a summary of the work that has been done, and the total amount it will cost, and other things. To configure it, some development may be required. This will be sent to the customers e-mail adress that has been stored in the Work Order level

Work Order PDF is provided “as is” in unmanaged state, therefore you are able to modify it the way you want.

![image](media://9b9ff186-5ac5-479e-832d-1c8b2fe06713)

> ℹ️ How it works in a nutshell – as soon as work order status (FIELDBUDDY__Status__c) is changed from **not closed** (OPEN, IN_PROGRESS and so ) to **closed** (CLOSED or CANCELLED),  and there is a signature attached to work order, and  and appropriate custom settings are enabled , work order may be generated and (if generated) emailed.  
> ℹ️ For email being sent – there should be Email (un) , (Email_UN__c) field specified at Work Order object

### Out of the box description

1. Work Order is Closed.
2. Trigger check the criteria to generate PDF and if all are positive -  calls async method **cls_WorkOrderPDFWebService.callPDFWebService**
  1. Why async – signature is inserted AFTER work order closure but in same transaction
3. That async method
  1. Creates (or updates) attachment related to Work Order that just got closed
  2. Check checkbox **Execute_Post_PDF_Generating_Actions_UN__c **on Work Order
4. When checkbox is checked, trigger checks the criteria to send the Email, and if positive
  1. Updates a checkbox **Execute_WO_PDF_Email_Workflow_UN__c **on Work Order
5. That checkbox triggers a Workflow that will send an email to Email_UN__c field on Work order

## Components

1. Web service that generate an pdf content class + tests
  1. `cls_WorkOrderPDFController`
  2. `cls_WorkOrderPDFWebService`
  3. `test_WorkOrderPDFWebService`
2. 2 helping components to display number and controllers for them - **LocalDateTime, LocalNumber **components
3. Main VF component to render PDF - **WorkOrderPDF** component
4. VF page to display component - **WorkOrderPDF** page
5. Trigger that execute a WS to fetch pdf body and fire's workflow (**tr_WO_pdf**)
6. Workflow that send email with pdf to end user
7. Email template used by trigger (unmanaged,  classic)
8. Custom settings (unmanaged fields on object `FIELDBUDDY__FieldbuddySettings__c` )
9. Fields on Work Order to track progress and determine if PDF is generated/emailed at work order level
10. Static resource with style - `WorkOrderPDF_css` static resource


## Settings 

| Label/Value | **Api Name** | Action |
| --- | --- | --- |
| SC PDF: Generate PDF UN False | `SC_PDF_GeneratePDF__c` | PDF would not be generated in any case |
| SC PDF: Generate PDF UN - True, SC PDF: Generate PDF Based On WO = false | `SC_PDF_GeneratePDFBasedOnWO__c` | PDF would be generated in any case regardless checkboxes on WO |
| SC PDF: Generate PDF UN - True, SC PDF: Generate PDF Based On WO = true | `SC_PDF_GeneratePDFBasedOnWO__c` | PDF would be generated in case if field on Work Order calledGenerate WO PDF Email Attachment is set to true (`Generate_WO_PDF_Email_Attachment_UN__c`) |
| SC PDF: Email To Customer UN - false | `SC_PDF_EmailToCustomer__c` | Email would not be send |
| SC PDF: Email To Customer UN - True, SC PDF: Email To Customer Based On WO = false, and PDF is generated | `SC_PDF_EmailToCustomerBasedOnWO__c` | Email would be send regardless checkboxes on WO |
| SC PDF: Email To Customer UN - True, SC PDF: Email To Customer Based On WO = true, and PDF is generated | `SC_PDF_EmailToCustomerBasedOnWO__c` | Email would be send in case if feild on WO called Send WO PDF Email To Customer is set to true (`Send_WO_PDF_Email_To_Customer_UN__c`) |

### Options matrix

| Label | SC PDF: Generate PDF UN | SC PDF: Generate PDF Based On WO UN | SC PDF: Email To Customer UN | SC PDF: Email To Customer Based On WO UN | Generate WO PDF UN | Send WO PDF UN | Result |
| --- | --- | --- | --- | --- | --- | --- | --- |
| **Object** | `FIELDBUDDY__FieldbuddySettings__c` | `FIELDBUDDY__FieldbuddySettings__c` | `FIELDBUDDY__FieldbuddySettings__c` | `FIELDBUDDY__FieldbuddySettings__c` | `FIELDBUDDY__Work_Order__c` | `FIELDBUDDY__Work_Order__c` |  |
| API | `SC_PDF_GeneratePDF__c` | `SC_PDF_GeneratePDFBasedOnWO__c` | `SC_PDF_EmailToCustomer__c` | `SC_PDF_EmailToCustomerBasedOnWO__c` | `Generate_WO_PDF_Email_Attachment_UN__c` | `Send_WO_PDF_Email_To_Customer_UN__c` | **if PDF is saved**<br>**If email is sent** |
| 1 | FALSE | ANY | ANY | ANY | ANY | ANY | NO PDF, NO EMAIL |
| 2 | TRUE | FALSE | FALSE | ANY | ANY | ANY | PDF, NO EMAIL |
| 3 | TRUE | FALSE | TRUE | FALSE | ANY | ANY | PDF, EMAIL |
| 4 | TRUE | FALSE | TRUE | FALSE | ANY | ANY | PDF, EMAIL |
| 5 | TRUE | FALSE | TRUE | TRUE | ANY | FALSE | PDF, NO EMAIL |
| 6 | TRUE | FALSE | TRUE | TRUE | ANY | TRUE | PDF, EMAIL |
| 7 | TRUE | TRUE | FALSE | ANY | FALSE | ANY | NO PDF, NO EMAIL |
| 8 | TRUE | TRUE | FALSE | ANY | TRUE | ANY | PDF, NO EMAIL |
| 9 | TRUE | TRUE | FALSE | ANY | TRUE | ANY | PDF, NO EMAIL |
| 10 | TRUE | TRUE | TRUE | FALSE | TRUE | ANY | PDF, EMAIL |
| 11 | TRUE | TRUE | TRUE | TRUE | TRUE | FALSE | PDF, NO EMAIL |
| 12 | TRUE | TRUE | TRUE | TRUE | TRUE | TRUE | PDF, EMAIL |


# What to do in case of problems


1. If WO PDF does not work, you need to do following checks
  1. Ensure that there is license assigned to a user that want to save it
  2. Ensure that **cls_WorkOrderPDFController** and **cls_WorkOrderPDFService** are available to end users by permission set or apex classes permissions
  3. All parent lookups are given at Work Order, Service Request, Installed Product, Location and Account level
  4. Settings are properly set according to settings matrix above
  5. Preview WO PDF for given work order by URL `/apex/WorkOrderPDF?id=<work order id>`
2. Code of WO PDF is unmanaged. You can do some changes to run that under your very own conditions, but then it is your responsibility to ensure that it works. Given guide is applied to default WO PDF version
3. In case if there are no signature – WO PDF is not generated. if there are multiple signature files – WO PDF will pick random one
4. Go to Apex Jobs in Setup. Check if there are any errors there
5. Please, ask @Volodymyr Antoniuk if there are any unknown questions