Custom list views

Each list has a primary view that is read-only. Users can save a copy of the primary view, and then make changes to the columns, Action Pane buttons, and filter criteria for the new view. When you install your integration, you may want to include some custom views for your lists. For instance, the sample integrating application includes a “High Revenue” view for the Leads list.

[spacer]

Custom list views are added when the integration is installed, before the list has even been accessed the first time. To add custom list views, you will register a procedure trigger for the CreateDefaultListViews procedure of the syListObj form. The following example shows this trigger registration for the sample integrating application.

l_result = Trigger_RegisterProcedure(script CreateDefaultListViews of form syListObj, TRIGGER_AFTER_ORIGINAL, script IG_CreateDefaultCustomListViews);
if l_result <> SY_NOERR then
	warning "Trigger registration for CreateDefaultListViews failed.";
end if;

The trigger processing procedure that runs in response this trigger must determine whether the primary and custom views have already been added. If they have, no action should be taken. If no views have been added, the script must add the primary view for the list. After the primary view is added, it must add each custom view, specifying the unique characteristics of each view. The custom view can specify a different set of columns to display, different items in the Action Pane, and special filtering criteria for the data. If the custom view doesn’t specify its own set of columns, Action Pane items, or filtering criteria, the settings from the primary list view will be used.

Filtering criteria is the most common change made for custom list views. Microsoft Dynamics GP uses a special syntax for defining the filtering criteria applied to a list. The syntax can be complex. Don’t attempt to write the filtering expression manually. Instead, in Microsoft Dynamics GP use the filter pane for the list to define the filter criteria. When you save the list view, the filter criteria will be saved in the SY07230 table in the DYNAMICS database. Copy the filter criteria from the FilterCritera column of this table for use in the script that will add the custom list view. For example, the following expression is the filtering criteria for the Leads list that restricts the data displayed to show leads with a potential revenue of $50,000 or greater. It was created using the filter pane for the Leads list, and then copied from the SY07230 table.

<criteria><or><and><eval property="PotentialRevenue" operator="is greater than and includes" value1="50000" value2="" /></and></or></criteria>

The following example is the trigger processing procedure that adds the custom list view for the Leads list in the sample integrating application. It uses the Exists() function of the syListViewObj form to find out whether views for the Leads list have been added. If they haven’t, it uses the CreateDefaultViewRecord() -- View function to add the primary view, and the CreateDefaultCustomViewRecord() function to add the custom view (named”High Revenue”). Finally, the procedure specifies the characteristics of the custom view. The columns and Action Pane items are unchanged from the primary view, so no script code is needed. New filter criteria are applied for the custom view. Notice how the filter criteria shown previously is converted into a string in the sanScript code. All quotes in this criteria string are replaced with the QUOTE constant. Functions from the syListViewFiltersObj form write the updated criteria for the custom list view.

local integer nStatus;
local long viewID;
local syListViewFiltersState syListViewFilters;
local FilterCriteria sFilterCriteria;

{Does the primary view exist for the list?}
if Exists(IG_PROD_ID, LISTID_LEADS, LIST_PRIMARYVIEWID) of form  syListViewObj = false then

	{Create the primary view record}
	nStatus = CreateDefaultViewRecord(IG_PROD_ID, LISTID_LEADS) of form syListViewObj;

	{Create the custom view record for the 'High Revenue' view}
	nStatus = CreateDefaultCustomViewRecord(IG_PROD_ID, LISTID_LEADS, "High Revenue", 1, viewID) of form syListViewObj;

	if nStatus = OKAY then

		{Add the information about the custom view.}

		{Add the columns for the custom view.}
		{If the custom view will have a different set of columns than the 
		 primary view does, call a routine that defines the columns. The
		 routine will be similar to the routine that creates columns for
		 the primary view, but will use the viewID that was returned 
		 when the custom view was created, rather than the constant
		 LIST_PRIMARYVIEWID. If the columns will be the same as the
		 primary view, no additional code is required.}

		{Add the Action Pane items for the custom view.}
		{If the custom view will have a different set of actions than the 
		 primary view does, call a routine that defines the actions. The
		 routine will be similar to the routine that creates actions for
		 the primary view, but will use the viewID that was returned 
		 when the custom view was created, rather than the constant
		 LIST_PRIMARYVIEWID. If the actions will be the same as the
		 primary view, no additional code is required.}

		{Define the filter criteria for the custom view}
		sFilterCriteria = "<criteria><or><and><eval property="+ QUOTE + "PotentialRevenue" + QUOTE + " operator=" + QUOTE + "is greater than and includes" + QUOTE + " value1=" + QUOTE + "50000" + QUOTE + " value2=" + QUOTE + QUOTE +  " /></and></or></criteria>";

		nStatus = Create(syListViewFilters, table syListViewFilters, IG_PROD_ID, LISTID_LEADS, viewID, MODE_CHG) of form syListViewFiltersObj;
		if nStatus = OKAY then
			call SetFilterCriteria of form syListViewFiltersObj,
				syListViewFilters,
				sFilterCriteria;

			nStatus = Commit(syListViewFilters) of form syListViewFiltersObj;
			call Destroy of form syListViewFiltersObj, syListViewFilters;
		end if;
	end if;
end if;


Documentation Feedback