Share via


How to: Implement Row Tracking

If you implement row tracking in your LightSwitch database, you can track who added or modified row-level data and when. If the Enable Created/Modified properties check box is selected, Created, CreatedBy, Modified, and ModifiedBy fields are automatically added to a table when a user changes data.

Note

This property is available for tables in the intrinsic database only. For attached data sources, you must implement row tracking in the data source.

The Created and Modified fields use the DateTimeOffset custom data type, which stores the date and time relative to Coordinated Universal Time (UTC). The CreatedBy and ModifiedBy fields use the Person custom data type. These four fields are hidden in the Data Designer, but they appear in the Screen Designer so that you can display them on a screen if you want.

If you implement row tracking, you can filter data based on a specific user by using the Current User global value. For example, you can allow users to display only those records that they created.

To implement row tracking

  1. In Solution Explorer, open the shortcut menu for an entity or table, and then choose Open.

  2. In the Data Designer, on the Perspective bar, choose the Server tab.

  3. In the Properties window, select the Enable Created/Modified properties check box.

    Note

    For new tables, that check box is selected by default.

To filter rows based on the current user

  1. In the Data Designer, on the Perspective bar, choose the Server tab.

  2. On the toolbar, choose the Query button.

  3. In the Query Designer, choose the Add Filter link.

  4. In the second list, choose CreatedBy.

  5. In the fourth list, choose Global.

  6. In the fifth list, choose Current User.

See Also

Tasks

How to: Add a Table to the LightSwitch Internal Database

Concepts

Working with the Person Data Type

Other Resources

Queries: Retrieving Information from a Data Source

Data: The Information Behind Your Application