Using Multiple Area and Length Units in Custom SQL Queries and Fields
Using Multiple Area and Length Units in Custom SQL Queries and Fields
To specify multi-units conversion and titles for views that use custom SQL in queries or fields, use SQL expressions.
Typically, the field SQL does not need to perform unit conversion. In these cases, add the
numericFormat="area"
property to the field. Web Central will convert the value calculated in SQL to
User Display Units
.
If you need to perform unit conversion in SQL, do not add the
numericFormat
property to the field.
// Area calculated in User-default Units in SQL. <field table="rm" name="vf_area_convertedArea"> <title>${messages['areaTitle']} ${user.areaUnits.convertedTitle}</title> <sql dialect="generic">area * ${User.areaUnits.conversionFactor}</sql> </field>
You can use the following expressions in view, panel, and field titles, and in custom SQL queries:
New Expression | Result if Display Multiple Units is off | Result if Display Multiple Units is on |
---|---|---|
user.displayUnits
|
"Imperial" or "Metric" |
|
user.areaUnits.title
|
"" |
"sqM" or "sqft" depending on the Base and User Units. |
user.areaUnits.convertedTitle
|
"" |
"sqM" or "sqft" – whatever is opposite the areaTitle. |
user.areaUnits.conversionFactor
|
0.0929 or 10.7643 depending on the Base and User Units. |
|
user.lengthUnits.title
|
"" |
"M" or "ft" depending on the Base and User Units. |
user.lengthUnits.convertedTitle
|
"" |
"ft" or "M" – whatever is opposite the lengthTitle. |
user.lengthUnits.conversionFactor
|
0.3048 or .2808 depending on the Base and User Units. |