Restocker_Service_Report__mdt

What is a Service Report

Some customers want to receive reports about their Service that contain specific information, or are formatted in certain ways.
Because Invoices are shaped by the requirements of finance platforms, we needed a new tool in order to meet this requirement.
Service Report Templates are how we can leverage DocGen to create these specialised reports for our customers.

A Service Report Template is made of a DocGen template and a Restocker_Service_Report__mdt record.

Creating Service Report Templates

The first step of creating a Service Report Template is to create the Drawloop (DocGen) Template.
After the Template has been created, the metadata record is made to enable access to the Report.

DocGen Template

Requirements:
Starting Object: Service__c
Type: Restocker Service Report
Require Contact Selection: False
Template Document Folder: restockerTemplates
Delivery Options: Download with Salesforce File as Storage Location (no other delivery methods)
Availability: PermissionSet - Restocker Restockist Permissions

The DocGen Template for a Service Report starts from the Service object.
It will most typically look at the Service's Opportunity as well as the Root Work Order and Child Work Orders for the Service record.
For an example of a typical DocGen Template, see the 'Restocker - Service Report - Asset With Line Items' Template.

Metadata

Each DocGen Template must have a corresponding Restocker_Service_Report__mdt record.
This record is what allows the Restocker App to know about the Service Report Template and grants access to the Template for a region.

Create a new Restocker_Service_Report__mdt record and fill in the required details.

Label: The name of the Template that will be shown to end users
Restocker Service Report Name: The canonical developer name of the Template
Drawloop Template ID: The record ID of the DocGen Template Package
DDP Delivery Option ID: The ID of the download delivery option for the Template Package
Email Template ID: If this Service Report has a custom Email Template for use when delivering to the customer, the ID of the Classic Email Template should be placed here.
If this field is left blank, the Email Template in the Restocker_Default_Settings__mdt will be used.
Region Checkboxes: Check the box for any regions that should have access to this Service Report Template.

Service Quotes

A Service Quote is a special type of Service Report that is intended to be used as a Quote/Estimate before a Service has been completed.

Unlike a Service Report, the Service Quote should give an estimate for a Service based on the 'Required Quantity' field rather than the 'Quantity' or Salesforce Standard 'Total' and 'Subtotal' fields.
To assist in building the Templates there are a couple of extra fields added to Work Orders and Work Order Line Items:

Work Order Line Item - Required Subtotal: A formula calculating Required_Quantity__c * UnitPrice
Work Order - Required Line Item Subtotal: A roll-up summarising the 'Required Subtotal' of the Work Order Line Items belonging to the Work Order

The Custom Metadata for a Service Quote Template must has isQuote__c checked.

Only one Service Quote Template should be available per State or Territory.