StringCompare Conditional
Schema
| key | type | required | description |
|---|---|---|---|
| type | string |
required | A string defining the type of conditional as stringCompare. |
| operator | string |
required | A string that defines the comparison operation to perform. Valid values are isEqual, isNotEqual, beginsWith, endsWith, contains, oneOf, notOneOf, isEmpty, and isNotEmpty. |
| string | string |
required | The string that will be used when evaluating the conditional. If the operator is oneOf or notOneOf this value should be a comma separated list of strings. |
| valueQuery | string |
optional | A JSONata query whose result will be used as the right operand in the comparison. The query must resolve to a single string value. If valueQuery is not provided, the data associated with the object containing the conditional is used for comparison. For example, a textOptions defined in a style on a table's column may include a conditional. If the valueQuery property is not defined, the conditional will be evaluated for each row in the table. See below for an example of how to apply string conditionals to tables. |
Example
The following example shows how to alter text formatting in a table column base on a string comparison. The SKU column contains a conditional textOptions object that will bold any value that that contains the string TFX.
{
"type": "Table",
"style": {"layoutOptions": {"width": 250}},
"columns": [
{
"rowDataQuery": "sku",
"rowStyle": {
"textOptions": {
"weight": "bold",
"condition": {
"type": "stringCompare",
"operator": "contains",
"string": "TFX"
}
}
}
},
{
"rowDataQuery": "qty"
},
{
"rowDataQuery": "total",
"rowStyle": {
"textOptions": {
"format": {
"type": "float",
"formatString": "C2"
}
}
}
}
],
"headerRows": {
"data": [["SKU", "Qty", "Total"]]
},
"rows": {
"dataQuery": "sales"
}
}
An example output of the table defined above showing conditional text formatting using a string comparison:
