Value formatters

What a value formatter is

A value formatter is a reusable, named transformation applied to a merged value at render time. It takes the raw value from Salesforce and returns a formatted version: a date in a chosen format, a number as currency, text lower-cased, and so on. Define it once, then apply it wherever you merge that kind of value.

Value formatters are stored as Value_Formatter__c records. Each has a Name (how you reference it) and a Formatter body.

Where they are used

The formatter body

The formatter body is an arrow function that receives an arguments object and returns the formatted result. Read the merged value from args.value, or destructure value as in these examples:

// EUDateFormat - render a date as dd/mm/yyyy
({ value }) => new Date(value).toLocaleDateString("en-GB");

// ToLowerCase - lower-case the text
({ value }) => value.toLowerCase();

You can create formatters for any transformation you need, for example a currency format:

// CurrencyGBP
({ value }) => new Intl.NumberFormat("en-GB", { style: "currency", currency: "GBP" }).format(value);

A formatter written as value => value.toLowerCase() receives the arguments object as value, so it cannot lower-case the field's text. Check older or copied formatter bodies against the examples above. The arguments object is existing behaviour; version 10.11.0 does not introduce a new formatter calling convention.

The function runs when the document renders, so the formatted result is what appears in the document and the PDF.

Available arguments

Argument Templates and Redlining 3B Sign Meaning
value Yes Yes The merged value to format.
element Yes No The merge element in the generated document.
contextObject Yes No The object context used for the merge.
scopeContentJSON Yes No Information about the current merge scope.
loadedObjectRecords Yes No Records already loaded for the document.
callout Yes No The server call helper.
field No Yes The Sign field configuration.

Templates support asynchronous formatters. 3B Sign formatters must return their result synchronously. Return a value even when the formatter also changes another part of a Template.

For conditional sections, HTML output and testing changes in Redlining, see Conditional content and HTML value formatters. That guide explains how to target the generated document, when a new Redline Request is needed, and how to avoid testing a cached formatter.

Applying a formatter in Templates

In the builder, insert your merge field, then open the merge chip's floating toolbar and choose a formatter from the Value Formatters dropdown. The expression gains a formatter suffix:

#{Opportunity.Id:CloseDate>EUDateFormat}
#{Opportunity.Id:Amount>CurrencyGBP}

The part after > is the formatter's Name. At render, the field value is fetched, then passed through the named formatter before being placed in the document.

Applying a formatter in 3B Sign

In the Sign builder, open an Output field's settings and pick a Value Formatter. The field's pre-filled value is formatted the same way.

Creating and managing formatters

Manage formatters from the Value Formatters tab, or create one directly from the formatter dropdown in the builder. Give it a clear Name (it is how templates reference it) and a formatter body. Because formatters are shared org-wide by Name, a well-named library of formatters keeps documents consistent.

Tips

Difference from function expressions

A value formatter transforms an existing merged value. A function expression produces a value on its own without needing an underlying field. Use a formatter to reshape data you are already merging, and a function to generate content.