---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# TransformerRuleList - Scoped, Global

# TransformerRuleList - Scoped, Global {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 19 minutes to read

The TransformerRuleList API enables you to create a list of rules
for transforming various types of JSON and XML data into name-value pair output.

This API works along with the Transformer and TransformerDefinition APIs. Together, these APIs transform XML nodes or any entity in a structured JSON document into an output of name-value pairs. Supported JSON entities including objects and elements within an array, such as strings, numbers, and other arrays.  
* The
  TransformerRuleList API enables you to create transformation
  rule lists that define what data in the source document to include in the output and
  how to transform the source data.

* The
  TransformerDefinition API associates a transformation rule list
  with a JSON/XML record path to define reusable transform definition objects. You can
  use a transform definition object to transform one or more source documents.

* The Transformer API performs
  the actual data transformation, one data entity at a time, using the specified
  transformation rule list to create the desired output data.

{#TransformerRuleListAPI__ul_odh_ghv_bkb}

When you instantiate the TransformRuleList object, you must define whether it describes a JSON or XML source document using the .fromJSON() or .fromXML() methods. For example:

`var trl = sn_tfrm.TransformerRuleList().fromJSON();` or `var trl =
sn_tfrm.TransformerRuleList().fromXML();`

Then use the addRule() method to define a transformation rule for each
element in the source document that you want to include as a name-value pair in the
output.  
Use "adapter methods", such as setName() or thenAdd(), to define how to manipulate data elements when the transformation is performed. Adapter methods work along with the addRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns. You can apply one or more adapter methods to each data transformation. Adapter methods enable you to do things such as:

* Concatenate text.
* Perform mathematical functions, such as add, subtract, divide, and multiply.
* Round values up or down (round up/down, ceiling/floor).
* Define whether to use the minimum or maximum value when comparing a source data element to a specified value.
* Apply a currency code.
* Convert between different units of measure.
* Format data elements.
* Apply patterns.
* Replace specified data elements with a specified value.
* Split and rearrange strings.
{#TransformerRuleListAPI__ul_nrx_yvv_phb}

You can use the TransformerRuleList class in both scoped and global server
scripts. When using this class in a scoped application, use the `sn_tfrm`
namespace identifier. Also, before this API is available in an instance, you must activate the
Transformation Service plugin (com.glide.transform).

## TransformerRuleList - addRule(String rule, String path) {#ariaid-title2}

Creates an entry in the associated transformation rules list which defines a field to
create in the output.
You can create rules for any element in a source document. For example,
`.addRule('ticker', '$.quote.symbol')` creates the field "ticker" in the
output and copies over the value in quote.symbol of the source.

Once you define a rule using addRule(), you then use adaptor methods,
such as thenAdd(), thenReplace(), and
thenFloor() to manipulate the rule's output data. You can define as
many adaptor methods as needed for a single rule. All adapter methods directly after an
addRule() call, until the next addRule() call, apply
to that rule. Adapter methods are cumulative with the result of all adapter methods being
the final value saved in the output field.

For example, in the following code snippet, thenMultiply() and
thenRoundDown() apply to addRule('change_percentage', '$.quote.changePercent'); addRule('close_price', '$.quote.close') starts a new rule. If the value in
$.quote.changePercent is .011, then the final output value is "1" (
.011 \* 100 rounded down to the ones position).  


      .addRule('change_percentage', '$.quote.changePercent') 
      .thenMultiply('100') 
      .thenRoundDown('0') 
      .addRule('close_price', '$.quote.close') 

The addRule() method also supports the parameter
summary; `.addRule('summary')`. This implementation
creates the name field "summary:" in the output, but does not correlate it to any field in
the source. You can then use the adaptor methods thenConcat() and
thenConcatSymbol() to modify the contents of the summary field.
{#TRL-addRule_S_S__table_hwn_wrb_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| rule | String | Name of the element in the destination output. |
| path | String | Optional. JSONPath or XPath to the data element in the source document. The adapter methods thenConcat() and thenConcatSymbol() do not require you to define this parameter if no other adapter methods are defined for the rule. All other adapter methods require this parameter. |
[Table 1. Parameters]

{#TRL-addRule_S_S__table_hwn_wrb_qhb} {#TRL-addRule_S_S__table_iwn_wrb_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 2. Returns]

{#TRL-addRule_S_S__table_iwn_wrb_qhb}  

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Stock Report 05022019 JSON')
      .addRule('ticker', '$.quote.symbol') 
      .addRule('change_percentage', '$.quote.changePercent') 
      .thenMultiply('100') 
      .thenRoundDown('0') 
      .addRule('close_price', '$.quote.close') 
      .thenAdaptCurrency('USD', false) 
      .addRule('summary') 
      .thenConcat('Shares of ') 
      .thenConcatSymbol('ticker') 
      .thenConcat(' closed at ') 
      .thenConcatSymbol('close_price'); 

## TransformerRuleList - setName(String name) {#ariaid-title3}

Defines a name for the associated TransformerRuleList object for logging
purposes.
{#TRL-setName_S__table_z2l_5hw_phb__entry__3}

| Name | Type | Description |
|-|-|-|
| name | String | Name to use to identify the associated TransformerRuleList object. Although the API does not force this name to be unique, it is helpful if they are unique within an instance. |
[Table 3. Parameters]

{#TRL-setName_S__table_z2l_5hw_phb} {#TRL-setName_S__table_afl_5hw_phb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 4. Returns]

{#TRL-setName_S__table_afl_5hw_phb}  

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Stock Report 05022019 JSON')
      .addRule('ticker', '$.quote.symbol') 
      .addRule('change_percentage', '$.quote.changePercent') 
      .thenMultiply('100') 
      .thenRoundDown('0') 
      .addRule('close_price', '$.quote.close') 
      .thenAdaptCurrency('USD', false) 
      .addRule('summary') 
      .thenConcat('Shares of ') 
      .thenConcatSymbol('ticker') 
      .thenConcat(' closed at ') 
      .thenConcatSymbol('close_price'); 

## TransformerRuleList - thenAdaptCurrency(String currencyCode, Boolean
outputNumericCurrencyValue) {#ariaid-title4}

Adds an adapter to the current rule that ties the specified currency code to the output
field defined in the associated addRule() call.
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenAdaptCurrency_S_B__table_akh_43w_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| currencyCode | String | Currency code to tie to the destination data element, such as USD, EUR, and GBP. |
| outputNumericCurrencyValue | Boolean | Optional. Flag that indicates whether to display the currency code. Valid values: * true: do not display the country code; numeric value only * false: display the country code {#TRL-thenAdaptCurrency_S_B__ul_djt_wlw_qhb} Default: false |
[Table 5. Parameters]

{#TRL-thenAdaptCurrency_S_B__table_akh_43w_qhb} {#TRL-thenAdaptCurrency_S_B__table_bkh_43w_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 6. Returns]

{#TRL-thenAdaptCurrency_S_B__table_bkh_43w_qhb}  

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Stock Report 05022019 JSON')
      .addRule('ticker', '$.quote.symbol') 
      .addRule('change_percentage', '$.quote.changePercent') 
      .thenMultiply('100') 
      .thenRoundDown('0') 
      .addRule('close_price', '$.quote.close') 
      .thenAdaptCurrency('USD', false) 
      .addRule('summary') 
      .thenConcat('Shares of ') 
      .thenConcatSymbol('ticker') 
      .thenConcat(' closed at ') 
      .thenConcatSymbol('close_price'); 

## TransformerRuleList - thenAdaptDuration(String inputDuration, String
outputDuration) {#ariaid-title5}

Adds an adapter to the current rule that converts the source field from one unit of
measure to another, such as from minutes to seconds or weeks to days.
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenAdaptDuration_S_S__table_x4x_1nw_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| inputDuration | String | Current unit of measure of the source field. Valid values: * NANOSECOND * MICROSECOND * MILLISECOND * SECOND * MINUTE * HOUR * DAY * WEEK {#TRL-thenAdaptDuration_S_S__ul_nwd_nnw_qhb} |
| outputDuration | String | Unit of measure to convert the source field to in the output. Valid values: * NANOSECOND * MICROSECOND * MILLISECOND * SECOND * MINUTE * HOUR * DAY * WEEK {#TRL-thenAdaptDuration_S_S__ul_aly_tnw_qhb} |
[Table 7. Parameters]

{#TRL-thenAdaptDuration_S_S__table_x4x_1nw_qhb} {#TRL-thenAdaptDuration_S_S__table_y4x_1nw_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 8. Returns]

{#TRL-thenAdaptDuration_S_S__table_y4x_1nw_qhb}  

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Stock Report 05022019 JSON')
      .addRule('ticker', '$.quote.symbol') 
      .addRule('change_percentage', '$.quote.changePercent') 
      .thenMultiply('100') 
      .thenRoundDown('0') 
      .addRule('close_price', '$.quote.close') 
      .thenAdaptCurrency('USD', false) 
      .addRule('daily', '$.quote.weekly') 
      .thenAdaptDuration('WEEK', 'DAY'); 

## TransformerRuleList - thenAdd(Number operand) {#ariaid-title6}

Adds an adapter to the current rule that adds the passed in value to the source
field.
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenAdd_N__table_qjx_kmc_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| operand | Number | Value to add to the source field. |
[Table 9. Parameters]

{#TRL-thenAdd_N__table_qjx_kmc_qhb} {#TRL-thenAdd_N__table_rjx_kmc_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 10. Returns]

{#TRL-thenAdd_N__table_rjx_kmc_qhb}  

    var transformerRuleList = new sn_tfrm.TransformerRuleList.fromJSON()
      .setName('Stock Report 05182019 JSON')
      .addSymbol('ticker', '$.symbol') 
      .addSymbol('change_percentage', '$.changePercent') 
      .thenMultiply('100') 
      .thenRoundDown('0') 
      .addSymbol('trade_price', '$.current_price')
      .thenAdaptCurrency('USD', false) 
      .addMultiply('$.trade_quantity')
      .thenAdd('4.5'); 

## TransformerRuleList - thenApplyMap(Object map) {#ariaid-title7}

Adds an adapter to the current rule that searches the associated source field for a
list of strings and replaces them in the output with the specified replacement
values.
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenApplyMap_O__table_azh_c3x_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| map | Object | Name/value pairs. * name: text to locate in the source data element * value: text to replace it with in the output {#TRL-thenApplyMap_O__ul_vtw_jbz_qhb} |
[Table 11. Parameters]

{#TRL-thenApplyMap_O__table_azh_c3x_qhb} {#TRL-thenApplyMap_O__table_bzh_c3x_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 12. Returns]

{#TRL-thenApplyMap_O__table_bzh_c3x_qhb}  
In this example, the thenApplyMap() call searches the source text in the
company_info field for Inc. and St. and replaces them with Incorporated and Street in the
company_info field in the output.

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Stock Report 05022019 JSON')
      .addRule('ticker', '$.quote.symbol') 
      .addRule('change_percentage', '$.quote.changePercent') 
      .thenMultiply('100') 
      .thenRoundDown('0') 
      .addRule('close_price', '$.quote.close') 
      .thenAdaptCurrency('USD', false) 
      .addRule('company_info', '$.quote.company_info') 
      .thenApplyMap({'Inc.': 'Incorporated', 'St.': 'Street'});

## TransformerRuleList - thenApplyPattern(String matchPattern, String outputPattern {#ariaid-title8}

Adds an adapter to the current rule that matches a specified regex pattern to content
in the source field and then replaces/reformats that content with a second regex pattern and
stores that value in the output.
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenApplyPattern_S_S__table_ehx_kww_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| matchPattern | String | Regex pattern to use to locate the text to replace/reformat. |
| outputPattern | String | Regex pattern to use to update the located text. |
[Table 13. Parameters]

{#TRL-thenApplyPattern_S_S__table_ehx_kww_qhb} {#TRL-thenApplyPattern_S_S__table_fhx_kww_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 14. Returns]

{#TRL-thenApplyPattern_S_S__table_fhx_kww_qhb}  
In this example, any company name that ends with "Inc." is transformed to "Incorporated",
such as Company Inc. to Company Incorporated.

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Stock Report 05022019 JSON')
      .addRule('ticker', '$.quote.symbol') 
      .addRule('change_percentage', '$.quote.changePercent') 
      .thenMultiply('100') 
      .thenRoundDown('0') 
      .addRule('close_price', '$.quote.close') 
      .thenAdaptCurrency('USD', false) 
      .addRule('company', '$.quote.company') 
      .thenApplyPattern('(.+)(\\w{3}\\.)', '$1Incorporated');

## TransformerRuleList - thenCeiling(Number operand) {#ariaid-title9}

Adds an action to the current rule to round the source field up at the decimal position
specified by the passed in value.
Unlike straight rounding where the number is rounded based on the value of the digit in the
specified decimal position (0-4 round down, 5-9 round up), ceiling always rounds up. For
example, the ceiling value for 2.156 and 2.152 is always 2.16 for the passed in decimal
position of 2; whereas for straight rounding the values would be 2.16 and 2.15 respectively.
For negative numbers, the ceiling operation makes the number more positive, as in the
ceiling value of -2.156 is -2.15; whereas the same number rounded up makes the value more
negative, -2.16.  
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenCeiling_N__table_jfb_5fd_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| operand | Number | Decimal position to the right of the decimal point at which to round the number up (apply ceiling). For example, if this value is 2 and the source data element is 6.421, the resulting value is 6.43. |
[Table 15. Parameters]

{#TRL-thenCeiling_N__table_jfb_5fd_qhb} {#TRL-thenCeiling_N__table_kfb_5fd_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 16. Returns]

{#TRL-thenCeiling_N__table_kfb_5fd_qhb}  

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Mortgage Rates 05022019 JSON')
      .addRule('interest_rate', '$.quote.interest_rate') 
      .thenCeiling('2') // Always round the interest rate up to the hundredths place 
      .addRule('monthly_payment', '$.quote.total_loan_amount') 
      .thenDivideBy('180'); 

## TransformerRuleList - thenConcat(String value) {#ariaid-title10}

Adds an adapter to the current rule that concatenates the passed in string to the
output field.
Unlike other adapter methods, this method does not have to be applied to a source field.
You can use this method to create completely new data strings in the output.  
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenConcat_S__table_njv_qtb_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| value | String | Text to concatenate to the end of the current data element. |
[Table 17. Parameters]

{#TRL-thenConcat_S__table_njv_qtb_qhb} {#TRL-thenConcat_S__table_ojv_qtb_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 18. Returns]

{#TRL-thenConcat_S__table_ojv_qtb_qhb}  

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Stock Report 05022019 JSON')
      .addRule('ticker', '$.quote.symbol') 
      .addRule('change_percentage', '$.quote.changePercent') 
      .thenMultiply('100') 
      .thenRoundDown('0') 
      .addRule('close_price', '$.quote.close') 
      .thenAdaptCurrency('USD', false) 
      .addRule('summary') 
      .thenConcat('Shares of ') 
      .thenConcatSymbol('ticker') 
      .thenConcat(' closed at ') 
      .thenConcatSymbol('close_price'); 

## TransformerRuleList - thenConcatSymbol(String symbol) {#ariaid-title11}

Adds an adapter to the current rule that concatenates the value of a field previously
defined in the rules list to the current output field.
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenConcatSymbol_S__table_wgh_nyb_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| symbol | String | Name of the rules list element to append to the output field. |
[Table 19. Parameters]

{#TRL-thenConcatSymbol_S__table_wgh_nyb_qhb} {#TRL-thenConcatSymbol_S__table_xgh_nyb_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 20. Returns]

{#TRL-thenConcatSymbol_S__table_xgh_nyb_qhb}  

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Stock Report 05022019 JSON')
      .addRule('ticker', '$.quote.symbol') 
      .addRule('change_percentage', '$.quote.changePercent') 
      .thenMultiply('100') 
      .thenRoundDown('0') 
      .addRule('close_price', '$.quote.close') 
      .thenAdaptCurrency('USD', false) 
      .addRule('summary') 
      .thenConcat('Shares of ') 
      .thenConcatSymbol('ticker') 
      .thenConcat(' closed at ') 
      .thenConcatSymbol('close_price'); 

## TransformerRuleList - thenDivideBy(Number operand) {#ariaid-title12}

Adds an adapter to the current rule that divides the source field by the passed in
value.
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenDivideBy_N__table_nzk_3tc_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| operand | Number | Value by which to divide the source field. |
[Table 21. Parameters]

{#TRL-thenDivideBy_N__table_nzk_3tc_qhb} {#TRL-thenDivideBy_N__table_ozk_3tc_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 22. Returns]

{#TRL-thenDivideBy_N__table_ozk_3tc_qhb}  

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Stock Report 05022019 JSON')
      .addRule('ticker', '$.quote.symbol') 
      .addRule('change_percentage', '$.quote.changePercent') 
      .thenMultiply('100') 
      .thenRoundDown('0') 
      .addRule('dividend_per_share', '$.quote.total_dividend') 
      .thenDivideBy('$.quote.total_shares'); 

## TransformerRuleList - thenDivideInto(Number operand) {#ariaid-title13}

Adds an adapter to the current rule that divides the passed in value by the source
field.
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenDivideInto_N__table_crn_s5c_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| operand | Number | Value into which to divide the source field. |
[Table 23. Parameters]

{#TRL-thenDivideInto_N__table_crn_s5c_qhb} {#TRL-thenDivideInto_N__table_drn_s5c_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 24. Returns]

{#TRL-thenDivideInto_N__table_drn_s5c_qhb}  

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Stock Report 05022019 JSON')
      .addRule('ticker', '$.quote.symbol') 
      .addRule('change_percentage', '$.quote.changePercent') 
      .thenMultiply('100') 
      .thenRoundDown('0') 
      .addRule('dividend_per_share', '$.quote.total_shares') 
      .thenDivideInto('$.quote.total_dividends'); 

## TransformerRuleList - thenFloor(Number operand) {#ariaid-title14}

Adds an adapter to the current rule that rounds the source field down at the decimal
position specified by the passed in value and stores it in the output.
Unlike straight rounding where the number is rounded based on the value of the digit in the
specified decimal position (0-4 round down, 5-9 round up), floor always rounds down. For
example, the floor value for 2.156 and 2.152 is always 2.15 for the passed in decimal
position of 2; whereas for straight rounding the values would be 2.16 and 2.15 respectively.
For negative numbers, the floor operation makes the number more negative, as in the floor
value of -2.156 is -2.16; whereas the same number rounded down makes the value more
positive, -2.15.  
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenFloor_N__table_zpl_tzc_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| operand | Number | Decimal position to the right of the decimal point at which to round the number down (apply floor). For example, if this value is 2 and the source data element is 6.427, the resulting value is 6.42. |
[Table 25. Parameters]

{#TRL-thenFloor_N__table_zpl_tzc_qhb} {#TRL-thenFloor_N__table_aql_tzc_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 26. Returns]

{#TRL-thenFloor_N__table_aql_tzc_qhb}  

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Mortgage Rates 05022019 JSON')
      .addRule('interest_rate', '$.quote.interest_rate') 
      .thenFloor('2') // Always round the interest rate down to the hundreths place 
      .addRule('monthly_payment', '$.quote.total_loan_amount') 
      .thenDivideBy('180'); 

## TransformerRuleList - thenFormat(String matchPattern, String outputPattern) {#ariaid-title15}

Adds an adapter to the current rule that reformats the content in the source field that
matches the specified match pattern, with the specified output pattern.
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenFormat_S_S__table_uv3_qsw_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| matchPattern | String | Pattern to match against the source field. Valid values: * @: any character * #: decimal digit * \\: literal escape (\\@ for the @ symbol) {#TRL-thenFormat_S_S__ul_zyx_p5w_qhb} |
| outputPattern | String | Pattern to replace the content with in the output. Valid values: * @: any character * #: decimal digit * \\: literal escape (\\@ for the @ symbol) {#TRL-thenFormat_S_S__ul_nth_jvw_qhb} |
[Table 27. Parameters]

{#TRL-thenFormat_S_S__table_uv3_qsw_qhb} {#TRL-thenFormat_S_S__table_vv3_qsw_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 28. Returns]

{#TRL-thenFormat_S_S__table_vv3_qsw_qhb}  
This example reformats the quote date from YYYY/MM/DD to YYYY MM-DD.

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Stock Report 05022019 JSON')
      .addRule('ticker', '$.quote.symbol') 
      .addRule('change_percentage', '$.quote.changePercent') 
      .thenMultiply('100') 
      .thenRoundDown('0') 
      .addRule('close_price', '$.quote.close') 
      .thenAdaptCurrency('USD', false) 
      .addRule('date', '$.quote.date') 
      .thenFormat('####/##/##', '#### ##-##'); 

## TransformerRuleList - thenMax(Number operand) {#ariaid-title16}

Adds an adapter to the current rule that compares the passed in value against the
source field and copies the greater of the two values to the output field.
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenMax_N__table_rjj_hyc_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| operand | Number | Value to compare to the source field. |
[Table 29. Parameters]

{#TRL-thenMax_N__table_rjj_hyc_qhb} {#TRL-thenMax_N__table_sjj_hyc_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 30. Returns]

{#TRL-thenMax_N__table_sjj_hyc_qhb}  

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Mortgage Rates 05022019 JSON')
      .addRule('lowest_interest_rate', '$.quote.interest_rate') 
      .thenMax('3.5') // Interest rate cannot be less than 3.5%
      .addRule('dividend_per_share', '$.quote.total_shares') 
      .thenDivideInto('$.quote.total_dividends'); 

## TransformerRuleList - thenMin(Number operand) {#ariaid-title17}

Adds an adapter to the current rule that compares the passed in value against the
source field and copies the lower of the two values to the output field.
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenMin_N__table_q3s_nwc_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| operand | Number | Value to compare to the source field. |
[Table 31. Parameters]

{#TRL-thenMin_N__table_q3s_nwc_qhb} {#TRL-thenMin_N__table_r3s_nwc_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 32. Returns]

{#TRL-thenMin_N__table_r3s_nwc_qhb}  

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Stock Report 05022019 JSON')
      .addSymbol('broker_fee_percentage', '$.quote.broker_fee') 
      .thenMin('10') // Maximum of 10% broker fee
      .addSymbol('dividend_per_share', '$.quote.total_shares') 
      .thenDivideInto('$.quote.total_dividends'); 

## TransformerRuleList - thenMultiply(Number operand) {#ariaid-title18}

Adds an adapter to the current rule that multiplies the source field by the passed in
value.
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenMultiply_N__table_smg_wqc_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| operand | Number | Value by which to multiply the source field. |
[Table 33. Parameters]

{#TRL-thenMultiply_N__table_smg_wqc_qhb} {#TRL-thenMultiply_N__table_tmg_wqc_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 34. Returns]

{#TRL-thenMultiply_N__table_tmg_wqc_qhb}  

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Stock Report 05022019 JSON')
      .addRule('ticker', '$.quote.symbol') 
      .addRule('change_percentage', '$.quote.changePercent') 
      .thenMultiply('100') 
      .thenRoundDown('0') 
      .addRule('close_price', '$.quote.close') 
      .thenAdaptCurrency('USD', false) 
      .addRule('summary') 
      .thenConcat('Shares of ') 
      .thenConcatSymbol('ticker') 
      .thenConcat(' closed at ') 
      .thenConcatSymbol('close_price'); 

## TransformerRuleList - thenReplace(String matchString, String replaceString) {#ariaid-title19}

Adds an adapter to the current rule that finds all text within the source field that
matches a specified string and replaces it with an updated string.
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenReplace_S_S__table_snf_q1x_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| matchString | String | String to match against the source field to identify the text to replace. |
| replaceString | String | String with which to replace the matching text. |
[Table 35. Parameters]

{#TRL-thenReplace_S_S__table_snf_q1x_qhb} {#TRL-thenReplace_S_S__table_tnf_q1x_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 36. Returns]

{#TRL-thenReplace_S_S__table_tnf_q1x_qhb}  
In this example, any company name that ends with "Inc." is transformed to "Incorporated",
such as Company Inc. to Company Incorporated.

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Stock Report 05022019 JSON')
      .addRule('ticker', '$.quote.symbol') 
      .addRule('change_percentage', '$.quote.changePercent') 
      .thenMultiply('100') 
      .thenRoundDown('0') 
      .addRule('close_price', '$.quote.close') 
      .thenAdaptCurrency('USD', false) 
      .addRule('company', '$.quote.company') 
      .thenReplace('Inc.', 'Incorporated');

## TransformerRuleList - thenRoundDown(Number operand) {#ariaid-title20}

Adds an adapter to the current rule that rounds the source field down at the decimal
position specified by the passed in value.
For negative numbers, the thenRoundDown() method makes the number more
positive; the round down value of -2.156 is -2.15. The thenFloor() method
makes the same number more negative, -2.16.  
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenRoundDown_N__table_kf4_thd_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| operand | Number | Decimal position to the right of the decimal point at which to round the number down. For example, if this value is 2 and the source data element is 6.427, the resulting value is 6.42. |
[Table 37. Parameters]

{#TRL-thenRoundDown_N__table_kf4_thd_qhb} {#TRL-thenRoundDown_N__table_lf4_thd_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 38. Returns]

{#TRL-thenRoundDown_N__table_lf4_thd_qhb}  

    var transformerRuleList = new sn_tfrm.TransformerRuleList90
      .fromJSON()
      .setName('Mortgage Rates 05022019 JSON')
      .addRule('interest_rate', '$.quote.interest_rate') 
      .thenRoundDown('2') // Always round the interest rate down to the hundredths place 
      .addRule('monthly_payment', '$.quote.total_loan_amount') 
      .thenDivideBy('180'); 

## TransformerRuleList - thenRoundUp(Number operand) {#ariaid-title21}

Adds an adapter to the current rule that rounds the source data element up at the
decimal position specified by the passed in value.
For negative numbers, the thenRoundUp() method makes the number more
negative; the round up value of -2.156 is -2.16. The thenCeiling() method
makes the same number more positive, -2.15.  
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenRoundUp_N__table_qbw_fjd_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| operand | Number | Decimal position to the right of the decimal point at which to round the number up. For example, if this value is 2 and the source data element is 6.422, the resulting value is 6.43. |
[Table 39. Parameters]

{#TRL-thenRoundUp_N__table_qbw_fjd_qhb} {#TRL-thenRoundUp_N__table_rbw_fjd_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 40. Returns]

{#TRL-thenRoundUp_N__table_rbw_fjd_qhb}  

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Mortgage Rates 05022019 JSON')
      .addRule('interest_rate', '$.quote.interest_rate') 
      .thenRoundUp('2') // Always round the interest rate up to the hundredths place 
      .addRule('monthly_payment', '$.quote.total_loan_amount') 
      .thenDivideBy('180'); 

## TransformerRuleList - thenSplit(String splitPattern, String replaceString) {#ariaid-title22}

Adds an adapter to the current rule that splits, reorganizes, and replaces strings
within the source field and saves them in the output field.
The splitPattern parameter denotes how to divide the source text
string into segments. This parameter can be a typical word separator such as a space (' '),
comma (','), or semicolon (';'), and can also be any string, such as 'name'. For example, if
the source text is "Smith John Michael" and the splitPattern is a
space, then the available segments are "Smith", "John", and "Michael". To reference a
segment, use $#, where # is the number of the order of the segment in the source text
string. For example, if the method call is `thenSplit(' ', '$2 $3 $1')`, then
the output is "John Michael Smith". In addition, you can add constants within the output
pattern, such as `thenSplit(' ', 'First name: $2 Middle name: $3 Last name:
$1')`.  
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenSplit_S_S__table_w4h_kfx_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| splitPattern | String | String that denotes how to split the text into segments. |
| replaceString | String | String that defines the output string, including segment references and constants. Not all segments need to be referenced. Reference the segments defined by the splitPattern using $#, where # is the number of the order of the segment in the source data element. Reference the entire source data element using $0. |
[Table 41. Parameters]

{#TRL-thenSplit_S_S__table_w4h_kfx_qhb} {#TRL-thenSplit_S_S__table_x4h_kfx_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 42. Returns]

{#TRL-thenSplit_S_S__table_x4h_kfx_qhb}  
In this example, the CEO name is last name, first name in the source data and in the output
it will be transformed to first name last name.

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Stock Report 05022019 JSON')
      .addRule('ticker', '$.quote.symbol') 
      .addRule('change_percentage', '$.quote.changePercent') 
      .thenMultiply('100') 
      .thenRoundDown('0') 
      .addRule('close_price', '$.quote.close') 
      .thenAdaptCurrency('USD', false) 
      .addRule('CEO', '$.quote.CEO') 
      .thenSplit(',', '$2 $1');

## TransformerRuleList - thenSubtract(Number operand) {#ariaid-title23}

Adds an adapter to the current rule that subtracts the passed in value from the source
field and stores it in the output field.
Note:  
This is an adapter method and cannot be used on its own. Adapter methods work in conjunction with theaddRule() method. They define adaptations to apply to the output field defined by the addRule() method such as formatting, rounding, and applying patterns.
{#TRL-thenSubtract_N__table_ptl_jpc_qhb__entry__3}

| Name | Type | Description |
|-|-|-|
| operand | Number | Value to subtract from the source data element. |
[Table 43. Parameters]

{#TRL-thenSubtract_N__table_ptl_jpc_qhb} {#TRL-thenSubtract_N__table_qtl_jpc_qhb__entry__2}

| Type | Description |
|-|-|
| Object | Current TransformerRuleList object. |
[Table 44. Returns]

{#TRL-thenSubtract_N__table_qtl_jpc_qhb}  

    var transformerRuleList = new sn_tfrm.TransformerRuleList()
      .fromJSON()
      .setName('Stock 05182019 JSON')
      .addRule('ticker', '$.quote.symbol') 
      .addRule('change_percentage', '$.quote.changePercent') 
      .thenMultiply('100') 
      .thenRoundDown('0') 
      .addRule('close_price', '$.quote.close') 
      .thenAdaptCurrency('USD', false) 
      .addRule('trade_price', '$.quote.current_price') 
      .addMultiply('$.quote.trade_quantity')
      .thenSubtract('$.quote.discount_dollars'); 


