Document Templates: Problem with the Display of number on a PDF Document Template

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2024 12:35 PM
I am working to replace our HR Document Templates with PDF Document Templates. I am having a problem because number and currency fields are not displaying with commas.
When I place number field (eg. Annual Salary) on a PDF Document Template when the signature form is generated in the Document Task there are no commas in that salary on the form. This is difficult to read and just looks stupid.
I selected the number format in the field mapping set up on the Document Template, but it looks like that is just a validation script for data entry. Do I seriously need to write code to format a field??? This was a non-issue on HR Document Templates. They displayed as numbers correctly with no additional work. I am just trying to rebuild the exact same form, so I am pointing at the exact same fields and getting this different behavior in PDF Document templates.
Any help or ideas will be appreciated?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2024 07:13 PM
@irene_mascari Use your PDF Document Template field mapping if it allows you to use a Scripted Field Mapping, you can write a simple script to format the number or currency field with commas.
For example, if you are mapping the Annual Salary field, use the following script in the field mapping:
(function transformValue(current) {
var salary = current.annual_salary || 0;
return salary.toLocaleString(); // This will format the number with commas (e.g., 1000000 -> "1,000,000")
})();
Hope this will help you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2024 07:13 AM
First, thank you for taking the time to try to help me.
I tried to implement the solution you suggested. I am not skilled in this area at all, so perhaps I did it incorrectly, but when I retested it returned a blank.
To implement, I replaced the default script that was in the Advanced Script section for the field with the code you provided. Was I supposed to instead somehow / somewhere embed it into the default code that was already there?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 08:00 PM
It looks like the first line is based on a transform map or something instead of a Document Template mapping script. Try this:
(function evaluateMappingFieldValue(taskGr /* GlideRecord for parent task */, mappingField /* Pre-computed mapping field value */) {
var salary = taskGr.subject_person_hr_profile.annual_salary || 0;
return salary.toLocaleString();
})(taskGr, mappingField);
Replace "subject_person_hr_profile.annual_salary" with the correct field you need to pull in (dot-walking as needed).