DATE_TIME_FROM
DATE_TIME_FROM:
arg: { arg } # required
format: { format } # required
nullValues: # optional
- { nullValue1 }
- { nullValue2 }
undeterminedIf: # required
invalidFormat: { message } # required
isEmpty: { message } # optional
Description
The DATE_TIME_FROM
operation converts a text (string) value into a DateTime
value. This is essential when dealing with date and time information represented as strings, allowing you to perform date-time comparisons and range checks within your policies. This operation ensures robust error handling by requiring you to specify outcomes for invalid or empty input strings.
Parameters
arg
(Operation<Text
>, required):format
(string, required):- Specifies the expected format of the
arg
string. - Currently supported value:
"ISO_8601"
. This indicates the string is in ISO 8601 format (e.g.,2023-10-26T10:00:00Z
,2023-10-26
).
- Specifies the expected format of the
nullValues
(list of strings, optional):- A list of custom strings that should be treated as
null
. If thearg
matches any string in this list (case-insensitively), the operation returns anull
DateTime
value, which is then treated as empty. This is useful for handling data that uses placeholders like "N/A" or "Not Applicable".
- A list of custom strings that should be treated as
undeterminedIf
(object, required):- A required block that defines how to handle potential errors during conversion, ensuring policies return an
UNDETERMINED
status instead of failing. invalidFormat
(string, required): The message to return if thearg
value cannot be parsed as a validDateTime
according to the specifiedformat
. This is crucial for handling malformed data.isEmpty
(string, optional): The message to return if thearg
value is empty (null
,""
, or whitespace-only). If this is not provided, an emptyarg
will be treated as an invalid format.
- A required block that defines how to handle potential errors during conversion, ensuring policies return an
Return Type
Examples
-
Basic Conversion
Converts a valid ISO 8601 string to a
DateTime
object.DATE_TIME_FROM:
arg:
EXTRACT: CA10__createdDate__c # Assumes extract returns an ISO 8601 string
format: "ISO_8601"
undeterminedIf:
invalidFormat: "The 'Created Date' is not in a valid ISO 8601 format." -
Handling All Error Conditions
This example shows a complete implementation that handles empty inputs and invalid formats separately.
DATE_TIME_FROM:
arg:
FIELD:
path: CA10__expirationDate__c
format: "ISO_8601"
undeterminedIf:
isEmpty: "The expiration date is missing."
invalidFormat: "The expiration date has an invalid format." -
Using
nullValues
to Handle PlaceholdersThis example correctly handles an input that might be a valid date, the string "N/A", or an invalid format.
IS_EMPTY:
arg:
DATE_TIME_FROM:
arg:
FIELD:
path: CA10__lastLogin__c # Field might contain a date or "N/A"
format: "ISO_8601"
nullValues:
- "N/A"
- "Not Applicable"
undeterminedIf:
invalidFormat: "The last login date has an invalid format."