--- alias: user-guide-automation-converter-anytoconstant description: "This converter transforms task outputs into a specified constant type" --- # Any to Constant The anyToConstant converter receives any kind of an output of a task ignores it and transforms it into a given constant. This is commonly used when for example, one wants to force a `Boolean` (true or false). ## Settings | Name | Possible Values | Description | |------ | ------- | ------- | | type | `Boolean`
`String`
`Integer`
`Long`
`Decimal`
`Object`
`Date` | Result type of the value to output | | value | | The value that will be output. Will be formatted to the type defined. | | dateFormat | `Now`
`UTCNow`
`Custom` | How the date is built when `type` is `Date` | | customDateValue | | The date to output when `dateFormat` is `Custom` | Table 1: Settings ![image118][image118] [image118]: ./images/image118.png ## Examples The input value is always ignored - the output is built entirely from `type` and `value` (and `dateFormat` / `customDateValue` when `type` is `Date`). The `value` field in the wizard adapts to the selected `type`, and the converter converts the stored value to that `type` at runtime. | `type` | `value` | Output | | --------- | --------------------------- | --------------------------------------- | | `Integer` | `12345` | `12345` (`Number`) | | `String` | `Hello...` | `Hello...` (`String`) | | `Boolean` | `true` | `true` (`Boolean`) | | `Boolean` | `NOT true` | `false` - see Boolean conversion note below | | `Decimal` | `123.45` | `123.45` (`Number`) | | `Object` | `{ "x": 123, "y": true }` | An `Object` whose properties can be accessed downstream as `result.x = 123`, `result.y = true` | Table 2: Examples Boolean conversion is case-insensitive and trimmed: `true`, `t`, `yes`, `y`, `1` all yield `true`; **anything else yields `false` without failing.** When `type` is `Date`, the output is driven by `dateFormat`: | `dateFormat` | `customDateValue` | Output | | ------------ | ------------------------ | ------------------------------------------------------------------ | | `Now` | N/A | Current **local** date/time. | | `UTCNow` | N/A | Current **UTC** date/time as an ISO string. | | `Custom` | `2024-08-12T12:00:00Z` | `2024-08-12T12:00:00Z` - passed through as-is, without validation | Table 3: Date Format Examples ### Invalid Input When the conversion from `value` to `type` cannot be done, the converter fails. For what happens to the rest of the chain when a converter fails (the error is logged, reported for monitoring, and the next task does not run), see [[user-guide-automation-converters-index]]. | `type` | `value` | Result | | ------------------ | --------------------------- | ------------------------------------------------------------ | | `Integer` / `Long` | `abc` (non-numeric) | Fails with `Unable to convert 'abc' to integer` | | `Decimal` | `abc` (non-numeric) | Fails with `Unable to convert 'abc' to decimal` | | `Object` | `{ invalid }` (bad JSON) | Fails because the value is not valid JSON. | Table 4: Invalid Input `String` and `Boolean` never fail - any value is converted to a string representation or to `true`/`false` respectively. `Date` with `dateFormat = Custom` does not validate `customDateValue`, so an invalid date string is passed downstream unchanged.