Advanced Report Helpers
Introduction
You use report helpers when creating templates to build FX Reports. Report helpers insert and format data on FX Reports. FieldFX supports Handlebars expressions to load data. A Handlebars expression is contained within two sets of curly braces.
{{labels.FX5__Price_Book__c}}
Handlebars expressions are further described and defined at https://handlebarsjs.com/.
To render data, you must combine Handlebars expressions with XML.
The Report Helpers below can be added to the XML template as XML elements if the <template>
tag has an attribute of preprocess="true"
.
-
The preprocess converts handlebars tags written as XML elements into their equivalent handlebars syntax.
-
This allows the XML author to write in XML without having to switch back and forth to Handlebars syntax.
<template pageSize="LETTER" pageOrientation="portrait" pageMargins="36 36 36 36" preprocess="true"> <header>header text</header> <body> body text ... <group collection="FX5__Ticket_Items__z" fields="RecordType.DeveloperName"> more text ... </group> </body> <footer>footer text</footer> </template>
The
<group>
element, a report helper, will be converted to the proper Handlebars syntax during preprocessing. -
Handlebars syntax can still be added to the XML document directly even with
preprocess="true"
.
Helpers and Helper Categories
These categories of helpers can be used:
Category | Helpers | ||
---|---|---|---|
|
Field Helpers
../
Navigates to the object’s parent to access a field on the parent object.
You can chain multiple ../ together to navigate to additional levels or #filters .
|
Use the following code to only list ticket items with a record type of Labor
, where the ticket items are marked as Billable, and where the item’s Catalog Item is categorized as Callout.
{{#filter FX5__Ticket_Items__r "RecordType.DeveloperName" is="Labor"}}
{{#filter items "Billable__c" is=true}}
>>{{#if ../../FX5__Category__c "==" "Callout"}}
{{#each items}}
{{/each}}
{{/if}}
{{/filter}}
{{/filter}}
-
The first
filter
helper excludes Ticket Items without a name value. -
The second
filter
helper excludes Ticket Items that not not marked as being billable. -
The
if
only includes items where the ticket item’s Catalog Item record is Callout.There are two ../
elements, going through a filter and a parent object to navigate to the Catalog Item record to access the Catalog Item’s Category field. -
Add expressions inside the
each
helpers to specify the fields to display for each item.
Use the following code to only list ticket items with a record type of Labor
, where the ticket items are marked as Billable, where the item is not hidden from reports, and where the item’s Catalog Item is categorized as Callout.
{{#filter FX5__Ticket_Items__r "RecordType.DeveloperName" is="Labor"}}
{{#filter items "Billable__c" is=true}}
{{#filter items "Hide_from_Report__c" is=false}}
>>{{#if ../../../FX5__Category__c "==" "Callout"}}
{{#each items}}
{{/each}}
{{/if}}
{{/filter}}
{{/filter}}
{{/filter}}
-
The first
filter
helper excludes Ticket Items without a name value. -
The second
filter
helper excludes Ticket Items that not not marked as being billable. -
The third
filter
helper excludes Ticket Items that are hidden from reports. -
The
if
only includes items where the ticket item’s Catalog Item record is Callout.There are three ../
elements, going through two filters and a parent object to navigate to the Catalog Item record to access the Catalog Item’s Category field. -
Add expressions inside the
each
helpers to specify the fields to display for each item.
Data Helpers
Labels (Deprecated)
The
|
Inserts field names.
Field names display in the language selected in the user’s record. |
<text>{{labels.FX5__Price_Book__c}}</text>
<text>{{labels.FX5__Job__r.FX5__CustomerAccount__c}}</text>
User Profile
Description |
Inserts data about the current user. |
|||||||||||
Available Fields |
The
|
|||||||||||
Example |
Use the following code to insert data from the Full Name field on the User object
|
Date & Number Helpers
formatCurrency
Description |
Formats currency fields. |
||||||||||||||||
Settings |
You can set the following for the
|
||||||||||||||||
Functions |
On the Sync 4.0 release channels, you can use the following functions inside the
|
||||||||||||||||
Examples |
Example 6. Use the following code to display monetary amounts as "12.345"
Example 7. Use the following code to display monetary amounts as "1.234.567,89"
Example 8. Use the following code to display monetary amounts as "€1,234.56"
Example 9. Use the following code to display monetary amounts as "USD 1,234.56
Example 10. Use the following code to display null values as blank entries
Example 11. Use the following code to display null values as "0"
Example 12. Use the following code to insert geolocation data with two decimal places
Example 13. Use the following code to insert the highest cost for a ticket item
Example 14. Use the following code to define empty values as 99.99% for the` FX5Discount_Percentc` on ticket items
|
formatDate
Description |
Formats date fields. |
||||||||
Settings |
You can set the following for the
|
||||||||
Functions |
On the Sync 4.0 release channels, you can use the following functions inside the
|
||||||||
Examples |
Example 15. Use the following code to display dates as "Jan 1st 17"
Example 16. Use the following code to display dates as "01.01.2017" and set German (de) as the locale
Example 17. Use the following code to insert the earliest start date and latest end date for a ticket item
|
formatDateTime
Description |
Formats date/time fields. |
||||||
Settings |
You can set the following for the |
||||||
Functions |
On the Sync 4.0 release channels, you can use the following functions inside the
|
||||||
Examples |
Example 18. Use the following code to display dates and times as "January 1st 2017, 1:00 PM"
Example 19. Use the following code to display dates and times as "01/01/17 8:30"
Example 20. Use the following code to display dates and times as "01/01/2017 08:30", with times in 24-hour format
Example 21. Use the following code to display dates and times as "1. January 2017 09:30 Uhr" and set German (
de ) as the locale
Example 22. Use the following code to insert the earliest start date/time and latest end date/time for a ticket item
|
formatPercent
Description |
Formats percentage fields. |
||||||||
Settings |
You can set the following for the
|
||||||||
Functions |
On the Sync 4.0 release channels, you can use the following functions inside the
|
||||||||
Examples |
Example 23. Use the following code to display percentages as "50%"
Example 24. Use the following code to display percentages as "50.00%"
Example 25. Use the following code to insert the highest discount percentage for a ticket item
|
formatTime
Description |
Formats time fields.
|
||||||||
Settings |
You can set the following for the
|
||||||||
Examples |
Example 26. Use the following code to display dates and times as "1:00 PM"
|
Geolocation Helper
Description |
|
||||||
Example |
Example 27. Use the following code to insert geolocation data with two decimal places
|
Math Helpers
You can use these math helpers:
avg
Description |
Inserts the average of a field in a collection. |
||||||||
Settings |
You can set the following for the
|
||||||||
Examples |
Example 28. Use the following code to insert the average Discounted Price for all ticket items
Example 29. Use the following code to insert the average discount percentage for all ticket items on a job.
|
formula
Description |
Inserts the calculated value of a formula.
|
||||||||
Examples |
Example 30. Use the following code to insert a value calculated by multiplying two field values (Price & Qty)
Example 31. Use the following code to insert a value calculated by dividing a subexpression by a number (ten)
Example 32. Use the following code to insert a value calculated by subtracting two calculated values
Example 33. Use the following code to insert data if there is a value in one of three designated fields
Example 34. Use the following code to highlight in gray every other row
|
sum
Description |
Inserts totals for fields in a collection. |
||||||||||||
Settings |
You can set the following for the
|
||||||||||||
Examples |
Example 35. Use the following code to insert the total Extended Amount for all ticket items.
Example 36. Use the following code to insert the total Extended Amount for all ticket items.
Example 37. Use the following code to return results where rounding is not done until the result is calculated
|
Logical Helpers
You can use these logical helpers:
collect
Description |
Builds a collection of items so that you can insert data for that collection. This helper is ideal for inserting totals for tickets and ticket items on job reports. |
||||
Data Variables |
You can use the following data variable inside the
|
||||
Examples |
Example 38. Use the following code to insert the total Extended Amount for all ticket items.
Example 39. Use the following code to insert the Ticket Log entries for all tickets.
|
each
Description |
Inserts the items in a collection for the specified object. |
||||||||||||||||||||||
Data Variables |
You can use the following data variable inside the
|
||||||||||||||||||||||
Iteration Variables |
|
||||||||||||||||||||||
Examples |
Example 41. Use the following code to insert a collection of labor ticket items
Example 42. Use the following code to insert a collection of ticket items with sequential item numbers starting at 0
Example 43. Use the following code to insert a collection of ticket items with sequential item numbers starting at 1
Example 44. Use the following code to insert data from an FX Form
Example 45. Use the following code to insert data from a child FX Form onto a report for the parent FX Form
Example 46. Use the following code to insert crew planning data for a job
Example 47. Use the following code to insert equipment planning data for a job
|
filter
Description |
Filters the items in a collection by a specified parameter, such as a field or record type.
|
||||||||||||||||
Data Variables |
You can use the following data variable inside the
|
||||||||||||||||
Examples |
Example 48. Use the following code to exclude non-labor ticket items
Example 49. Use the following code to insert the total number of labor ticket items
Example 50. Use the following code to exclude ticket items with an Extended Amount of $0.00
Example 51. Use the following code to exclude ticket items that aren’t parent or child items
Example 52. Use the following code to include tickets in the "Ready for Signature" status and "Equipment" ticket items only
|
filterBy
Description |
Filters the items in a collection based on a formula. |
||||
Settings |
You can set the following for the
|
||||
Limitations |
|
||||
Examples |
Example 53. Use the following code to exclude ticket items with price of $0.00
Example 54. Use the following code to exclude ticket items that don’t have notes entered
Example 55. Use the following code to exclude ticket items that don’t have notes entered and name the returned ticket items "ticketitems"
Example 56. Use the following code to set an IF statement to choose which field to filter by. In this scenario, it is based on a Ticket Field value, determining if it’s the SyncID or Parent Ticket Item field
|
group
Description |
Groups the items in a collection by a specified parameter, such as a field or record type.
|
||||||||||||||
Settings |
You can set the following for the
|
||||||||||||||
Data Variables |
You can use the following data variable inside the
|
||||||||||||||
Iteration Variables |
You can use the following iteration variables inside the
|
||||||||||||||
Examples |
Example 57. Use the following code to group ticket items by record type.
Example 58. Use the following code to group ticket items by record type and sort them by record type.
Example 59. Use the following code to group labor ticket items by employee.
Example 60. Use the following code to group labor ticket items by employee, arranged in order of clock in and clock out times when multiple items are found for the same employee.
|
if
Description |
Inserts data conditionally. |
||||||||||||||||||
Settings |
You can set the following for the
|
||||||||||||||||||
Operators |
You can use the following operators inside the
|
||||||||||||||||||
Data Variables |
You can use the following data variable inside the
|
||||||||||||||||||
Iteration Variables |
You can use the following iteration variables inside the
|
||||||||||||||||||
Examples |
Example 61. Use the following code to insert notes if they exist. If no notes exist, the if helper inserts the "There are no notes available" message.
Example 62. Use the following code to insert a checkbox from an FX Form.
Example 63. Use the following code to insert ticket items with an Extended Amount greater than or equal to $1.00. If items have an Extended Amount below $1.00, the if helper doesn’t insert them.
Example 64. Use the following code to insert a conditional message.
Example 65. Use the following code to insert data if there is a value in one of three designated fields on an FX Form.
Example 66. Use the following code to insert a Total Discount amount for all ticket items if there were any discounts applied. If there were no discounts applied, the
if helper doesn’t insert the Total Discount amount.
Example 67. Use the following code to insert a comma between ticket item date ranges in a list but don’t add a comma after the last date range.
Example 68. Use the following code to list only ticket items in a ticket report that have a 'not labor' record type.
|
sort
Description |
Sorts the items in a collection by a specified parameter, such as a field or record type. |
||||||||||
Settings |
You can set the following for the
|
||||||||||
Data Variables |
You can use the following data variable inside the
|
||||||||||
Iteration Variables |
You can use the following iteration variables inside the
|
||||||||||
Examples |
Example 69. Use the following code to insert ticket items sorted in descending numerical order by Extended Amount
Example 70. Use the following code to insert ticket items sorted in alphabetical order by description and insert sequential item numbers starting at 0.
Example 71. Use the following code to insert ticket items sorted in alphabetical order by description and insert sequential item numbers starting at 1.
|
unless
Description |
Inserts data conditionally. |
||
Examples |
Example 72. Use the following code to insert the Price for a ticket item if the On Standby checkbox isn’t selected.
|
with
Description |
Puts you in the context of the specified object so you can insert data for that object. This helper is ideal for inserting job data on ticket reports. |
||||
Examples |
Example 73. Use the following code to job data.
Example 74. Use the following code to insert crew planning data for a job.
Example 75. Use the following code to insert equipment planning data for a job.
|
Image Helpers
captureImage
Description |
Inserts an interactive image placeholder. Use this placeholder to attach an image to a report, such as a photo or stamp. Figure 1. The captureImage Report Helper allows you the user to attach a photo while completing a report
|
||||
Settings |
You can set the following for the
|
||||
Limitations |
|
||||
Examples |
Example 76. Use the following code to insert a 2 in x 1 in image placeholder.
Example 77. Use the following code to insert a 2 in x 1 in image placeholder with a 500px size limit.
|
Signature Helpers
signatureBlock
Description |
Inserts an interactive signature line. Use this signature line to capture digital signatures. |
Limitations |
You can’t use the Use the <signatureBlock> element to insert signature lines on PDF reports. |
Examples |
Use the following code to insert a basic signature line
When you insert a signature line, you also need to add CSS code to specify the style and image to use for the signature line. The image for the signature line embeds in the code using the base64 string format.
Example 78. Use the following code to insert a signature line with a watermark.
Figure 2. This example signature block uses the ticket tracking number as the watermark for the signature line.
When you insert a signature line with a watermark, you also need to add CSS code to specify the styles to use for the signature line and watermark. The image for the signature line embeds in the code using the base64 string format.
|
Advanced Helpers
We fixed an issue where the bold, italic, and underline formatting for a Report PDF wasn’t working. Those formatting controls now work when the report is made into PDF and rendered. |
applyTemplate
Description |
Applies Handlebars expressions to the contents of a designated value. |
Examples |
Example 79. Use this code to create a Job report
Copy and the past this code into the Notes field.
Figure 3. As the example shows, the resulting text from the Notes field displays in bold text.
Example 80. Use the following code to render a localized report.
Prerequisites
|