Format Value

Build a formatted string using one or more input values. This includes adding various types of formatting to numbers and dates/times, and converting them to a string.

Inputs

InputValue
formatStringRequiredA format string, using .NET composite formatting. For instance, "Today is {0:dddd dd MMMM}" would convert a date input in formatInput1 into day of week, day and month; the result formattedValue might read "Today is Thursday 3 May".
formatInput#OptionalInputs for the format string. In the format string, formatInput1 will be referenced as {0}, formatInput2 as {1}, etc.

While these are optional, you will typically want to have at least one format input.

Outputs

KeyValue
formattedValueThe resulting formatted value after the format string is resolved.

Usage

Two uses for this action are:

  • Formatting a number or date in some way (e.g. expressing a number as a currency or expressing a date as dd/mm/yyyy). This is often useful when an input in a GoFormz form or a third-party field is expected in a certain format.
  • Combining multiple inputs into a single string. This can be useful for constructing a descriptive sentence summarizing a transaction, for instance.

In the example below, we illustrate both these uses by combining several inputs from a completed form into a more readable summary string, and formatting each input appropriately along the way. The inputs here are a date field and two numeric fields from the completed form, and the formatString reads "On {0:D}, purchased {1:C2} of equipment at a {2:P1} discount." This means the date is converted to long form that includes the day of the week, the first number is converted to currency with 2 decimal points, and the second number is converted to percent with 1 decimal point. So the result formattedValue may read something like "On Thursday, May 3, 2018, purchased $107,063.25 of equipment at a 15.9% discount." In this example, the formatted string is then sent to a Salesforce object via the Salesforce: Update Object action.

1044