Product Note: Understanding Logical Properties
In this edition, we'll shed light on the often overlooked capability of Mobility to create logical properties or virtual fields.
Logical Properties:
Logical properties empower us to execute arbitrary SQL statements within our SELECT queries, enabling us to generate custom values or represent physical values in bespoke formats for display within our Mobility screens.
Case Study:
A valued Trimin customer mandated to submit reports to the FAA. The FAA requires dates in a non-standard format.
This customer raised a ticket seeking guidance on formatting dates precisely for a PDF report.
While Mobility typically allows date formatting using standard short or long formats, these options weren't suitable for this unique requirement.
The solution? Enter logical properties. By leveraging SQL expressions, we crafted a custom format for the date field, precisely meeting our customer's needs.
Example:
TO_CHAR(date, 'DD MON YYYY')
This expression converts the SQL date object into a string with the desired format: DD MON YYYY.
Should our date field be stored as a millisecond integer timestamp, a variant of this strategy could be employed:
TO_CHAR(TO_TIMESTAMP(int_date / 1000), 'DD MON YYYY')
Logical properties offer versatility, supporting a range of SQL functions for:
- String manipulation
- Concatenation
- Conditional operations
- Mathematical calculations
- Use of static values or constants
And much more! Leveraging SQL server execution, they typically offer high performance, though caution is advised with non-indexed column lookups.
Explore the full range of PostgreSQL query functions for further reference.
Logical properties are a powerful tool!
Embrace them to enrich your Mobility applications with custom functionalities.