Before getting started, make sure you have the following items at the ready:
Printing without a PDF is recommended when your use case allows it. "Raw" or "ZPL" printing is superior for two reasons:
When you would use PDFs over raw printing:
In this example we will be printing an asset tag from the Asset standard object in Salesforce. We will walk through the necessary changes in Salesforce to enable this. You can read along or follow exactly to reproduce this in your own org for whatever customer or standard object you require.
First, for this example and in the interest of time, we are providing sample ZPL that will be used. For a detailed walk through of how you would adjust this on your own read this guide.
^XA
^PW400
^LL200
^LH0,0
^CF0,17
^FO160,15^FDProperty of^FS
^FT0,50^A0,20,20^FB400,1,0,C^FH\^FD{!recordId.Account.Name}^FS
^CF0,30
^FO20,75^FD{!recordId.Product2.Name}^FS
^BY2,2,50
^FO30,120^BCN,40,Y,N,N^FD{!recordId.SerialNumber}^FS
^XZ
A screen flow is used to merge in record data into the ZPL template before then triggering the mobile print.
Merge fields from records can be merged into the merge field areas. Those areas highlighted you can merge in any fields you wish to be printed. For this example we keep it simple with standard fields on the Asset object.
API Name: The API name of the component. This can follow any naming convention you prefer.
Auto Print on Open: This determines whether or not the print triggers immediately once the user arrives at this screen. We recommend setting this to {!$GlobalConstant.True} to ensure it print immediately without requiring the user to tap a print button once more to confirm. Otherwise, setting this to {!$GlobalConstant.False} will render a button for the user to print.
Button Label: If the previous field was set to {!$GlobalConstant.False}, this field determines the label of the button text that the user will see on their screen.
Button Style: This determines the style of the button. We default to brand which is just the generic brand color in your org (often blue). Options include: success, text-destructive, destructive, outline-brand, brand, and neutral. More details can be found here.
Copies: This number determines the number of copies to be printed. If you plan to utilize copies, we recommend you read this guide for handling copies.
Type: This field tells the app if the type of printing if pdf or raw. Since this is raw printing the value for this field should be RAW. For pdf printing it would be set to PDF.
PDF Record ID: This is for the contend document record Id. This tells the package which content document should be sent for printing. In the case of raw printing, this is not relevant and can be left blank.
PDF Scale Mode: This tells the app whether a PDF should FIT to the media (scale automatically up or down to fit) or print exact size ACTUAL (potentially having content spill off the media). A value of FIT ensures the content scales to fit while a value of ACTUAL prints the actual size. In the case of raw printing, this field is not relevant.
Raw Body: This is the raw content or in this case ZPL that is being sent to be printed. This is where you would include the text template you created.
You should now see the action in Salesforce Mobile. Trigger a print to test. If you run into any issues, reach out to us.