Examples: Exists()


The following example is a trigger processing procedure from the sample integrating application. It creates a custom view for the Leads list in the sample integration. It uses the Exists() function to determine whether the primary view for the Leads list has been created. If it has not, it uses the CreateDefaultViewRecord() -- View and the CreateDefaultCustomViewRecord() functions to create the custom view. This custom view defines new filter criteria for the list.

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.}
		{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