Date and Time Expressions in FSM Mobile
This topic is intended for administrators and developers who configure date and time expressions in Field Service Management (FSM) Mobile.
The following table lists helpers for FSM Mobile expressions.
|
Helper |
Purpose |
Result |
|---|---|---|
|
|
Formats a date-like value. |
An object containing |
|
|
Gets the current date and time when the expression runs. |
An object containing |
These helpers are for FSM Mobile expressions. Don't assume that these helpers are available in server-side template tags.
This topic includes the following sections:
Date and Time Result Formats
The following table lists the required formats for nonempty date and time values.
|
Element Type |
Required Nonempty Value |
Example |
|---|---|---|
|
Date |
|
|
|
Time |
|
|
|
Date-Time |
|
|
Use format(value).date, format(value).time, or format(value).datetime as appropriate. These helpers don't perform a business-specific time zone conversion. Account for the intended time zone when choosing the source value.
A blank input to format() is treated as the current date and time. Guard a blank source value if the result should remain blank.
For example:
{
"sourceDateTime": {
"type": "datetime",
"label": "Source Date-Time",
"value": ""
},
"derivedTime": {
"type": "time",
"label": "Derived Time",
"readonly": true,
"value": "sourceDateTime.value ? format(sourceDateTime.value).time : ''"
}
}
If format() cannot parse a date-like value, the helper can return empty strings. Invalid expression results are not guaranteed to be ignored or restored to a previous value. Check the result and the element's validation requirements.
Capturing the Current Time
Include a recognized input that determines when the current-time expression should run. The following fragment sets the time when the Use Current Time box is checked and clears the time when the box is cleared:
{
"useCurrentTime": {
"type": "checkbox",
"label": "Use Current Time",
"value": false
},
"capturedTime": {
"type": "time",
"label": "Captured Time",
"step": 60,
"value": "useCurrentTime.value ? now().time.replace(/:\\d\\d$/, ':00') : ''"
}
}
The helper now().time includes seconds. In this example, the replacement sets the seconds to 00 for a minute-aligned result. It doesn't round to the next minute. Use this approach when the configured time entry and its destination require minute-aligned values.
The now() helper samples the time when the expression runs. It doesn't continuously update the element over time. A bare string such as "now().time" also lacks the element-property reference needed to establish the binding.
For element limits, defaults, and time-step behavior, see FSM Mobile Element Reference.