Newer Version Available

This content describes an older version of this product. View Latest

Create a Service Report with Apex

The Create Service Report action on work orders, work order line items, and service appointments can also be called using Apex code. The following code example creates a service report with two signatures by making an Apex callout to the createServiceReport action REST API resource.
Each service report contains data from its parent record and signatures from customers, technicians, or others who need to sign off on the work. In your API call, you can define one or more signatures to be used in the report. The number and type of signatures must match the service report template's signature settings.
  • This code example applies to API version 41.0 and later. Service reports generated with API version 40.0 can contain only one signature.
  • This code example assumes that you have remote site settings enabled to make REST callouts. For more information, see Adding Remote Site Settings.
  • The mock record ID in the code example is 0WOxx000000001E. The mock service report template ID is 0SLR00000004DBFOA2.

Note

API Endpoint (v41.0): /services/data/v41.0/actions/standard/createServiceReport
1{
2       "inputs" : [ {
3          "entityId" : "0WOxx000000001E",
4             "signatures" : [
5                      {"data":"Base64 code for the captured signature image",
6                      "contentType":"image/png",
7                      "name":"Customer Signature",
8                      "signatureType":"Customer",
9                      "place":"San Francisco",
10                      "signedBy":"John Doe",
11                      "signedDate":"Thu Jul 13 22:34:43 GMT 2017"               
12                      },
13                      {"data":"Base64 code for the captured signature image",
14                      "contentType":"image/png",
15                      "name":"Technician Signature",
16                      "signatureType":"Technician"
17                      }],
18             "templateId" : "0SLR00000004DBFOA2"
19       } ]
20    }

Field Descriptions

  • entityId—The ID of the work order, work order line item, or service report for which you want to create the service report.
  • signatures—A list of JSON definitions for a digital signature.
    • data—(Required) The base64 code for an image.
    • contentType—(Required)The file type of the signature.
    • signatureType—(Required) The role of the person signing; for example, “Customer.” Signature Type picklist values are defined by the Salesforce admin ahead of time. Each signature block must use a different signature type, and the signature types you define in your call must match the service report template’s signature types.
    • name—The signature block title. This value appears on the generated service report.
    • place—The place of signing. This value appears on the generated service report.
    • signedBy—The name of the person signing. This value appears on the generated service report.
    • signedDate—The date of signing. This value appears on the generated service report.
  • templateId—The ID of the service report template used for the report. To find the ID, run a SOQL query on the ServiceReportLayout object in Workbench.