Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics

Data formatting

Scroll Prev Next More

 

The data is stored in a raw format in the database. For example, the Date type data is stored as yyyy-mm-dd. For pages like List, View, Print, you can customize data appearance by defining the View as settings in Page Designer.

Using the formatted data in events. ViewControl::Format function

If there is a need to use formatted data in events, for example, when sending emails to users, you can use the ViewControl_Format function.

Syntax

 

ViewControl_Format(data, FieldName, TableName)

Arguments

data

raw data to be formatted.

FieldName

the field that contains the data to be formatted.

TableName

the name of the current table

Example 1

Using the ViewControl_Format function in the AfterAdd event:

 

Response.Write values("Date Listed") & "<br>"
Response.Write ViewControl_Format(values, "Date Listed", "Cars")

 

The first line of the code sample displays raw data (e.g., 2014-10-15), the second one - the formatted data (US date format, e.g., 10/15/2014).

Example 2

If you need to use this function in button's server code (where you do not have access to values array) this is what you can do. This will work with the button added to View/Edit pages or with the button button inserted into the grid:

 

DoAssignment data, button.getCurrentRecord()
dateListed = ViewControl_Format(data, "Date Listed", "Cars")

 

This function can also be used for a Lookup wizard field. In this case, raw data is stored in the Link field, and the ViewControl_Format function displays the values of the Display field.

See also:

Button object: getCurrentRecord()

"View as" settings

"Edit as" settings: Lookup wizard

Events: AfterAdd