What would you like to know more about?

Advanced Techniques for Views

Explore advanced techniques for managing and customizing views in MinistryPlatform, including the use of custom SQL, tokens, and specific SQL functionalities to enhance user interaction and data handling.

When you need to add custom SQL using the Page Views page, it is often helpful to begin on the page where the view exists. Then save the view, and go to System Setup > Page Views to edit the view.

Note: Once you enter custom SQL into the setup page, you can't edit that SQL in Form Layout mode.

Tokens

  • dp_UserID: Represents the ID for the user currently logged in to the Platform.
  • dp_ParentID: Represents the ID for the parent record of any sub-page record.
  • dp_DomainTime: Represents the current time according to the time zone set in the domain record.

For example, you could create a filtered page called "My Opportunities" where users with access to that page would only see the opportunities for which they are the contact person. The filter clause for such a page is:

Contact_Person_Table.User_Account = dp_UserID

Sort Order

The view automatically sorts by the first column unless you specify a sort order. To specify a sort order, list the field names in a comma delimited list. If you are using a subquery, use the alias assigned in the field list.

Filter Only Fields

In SQL, you can use fields for filters without them displaying in the results. To do this, omit the field from the SELECT clause. In the following example, notice the date of birth is in the WHERE clause but not in the SELECT clause:

SELECT Contact_ID, Display_Name
	FROM Contacts
	WHERE Date_of_Birth IS NOT NULL

In the Advanced Search Tool, delete the field from the Field List field in the SQL Layout tab:

Image displaying SQL Layout tab of the Advanced Search Tool. In the Field List section is the SQL code to retrieve the contact ID, display name, and date of birth. The date of birth code is highlighted, indicating it is being deleted. The Filter Clause section has the SQL code to retrieve contacts where the date of birth value is not null.

As a result, the field's checkbox is deselected with a comparison in the Form Layout tab:

Image displaying the Form Layout tab of the Advanced Search Tool. The contact ID and display name fields have blue checkboxes that are selected. The date of birth field checkbox is not selected, with the NOT NULL in the comparison column.

Default Field List (Filter Only View)

To use the same field list as the page (All Record view), you can clear the Field List field in the SQL Layout tab:

Image displaying the Active Status vs. Activity view open to the SQL Layout tab. The fields in the Field List section are highlighted, indicating they are being deleted. There are still fields in the Filter Clause section.