Selecting the data to display

Two procedures you supply for the list are used to control what data will be displayed. The first of these is the GetSortIndex procedure. This procedure examines the column the user has selected to sort the list contents, and then creates a virtual key for the primary table used for the list. Data in the list will be sorted using this key.

The following is the GetSortIndex procedure for the Contact History list in the sample integrating application. Notice that pass-through sanScript is used to create a virtual key for the main table used for the Contact History list.

in string sFieldName;
in ColSortOrder nSortOrder;
inout ListObjState list_object;

local text sCommand;
local string sCompileMSG;
local integer DictID = IG_PROD_ID;

pragma(disable warning LiteralStringUsed);

sCommand = "inout ListObjState Me; assign Me:SortIndex as key for " + "table(Me:'Table Reference') " + "with KEY_OPTION_ALLOW_DUPLICATES using '" + sFieldName + "'" + " of table(Me:'Table Reference')";

if nSortOrder = COLSORTORDER_DESCENDING then
	sCommand = sCommand + " with KEY_SEGMENT_OPTION_DESCENDING";
end if;
if sFieldName <> technicalname('Customer Number' of table(list_object:'Table Reference')) then
	sCommand = sCommand + CH_COMMA + "'Customer Number'" + " of table(Me:'Table Reference')";
end if;
sCommand = sCommand + ";";

if execute (DictID ,sCommand, sCompileMSG, list_object) <> 0 then
	warning "Error: " + sCompileMSG;
end if;

pragma(enable warning LiteralStringUsed);

The rows displayed in the list depend on several factors, such as the selection option the user chose, the specified date range, or any search restrictions the user has applied. The SetRange procedure applies the appropriate range to the main table for the list, accounting for any predefined selections or search criteria the user has specified.

The following is the SetRange procedure for the Contact History list. It creates a set of range selection criteria based on the user’s predefined selection, the specified date range, and any filter options specified through the Filter Pane at the top of the list. Every column that can be displayed in the list must be included in the range restriction. The range where statement is used to apply the range to the main table for the list.

inout ListObjState list_object;

local string sRestrict;
local string sFind_SQL;
local text sRestriction;

default window to State;

range clear table(list_object:'Table Reference');

{Active Only restriction }
if list_object:ListOptionValue = LISTOPTION_CONTACTSACTIVE then
	sRestriction = physicalname('Inactive' of table ContactHistoryTrxTemp) + CH_EQUAL + str(0);
end if;

{Apply any range restrictions based on the date range specified}
if not (empty(list_object:'Start Date') and empty(list_object:'End Date')) then
	if not empty(sRestriction) then
		sRestriction = sRestriction + CH_SPACE + SQL_AND + CH_SPACE;
	end if;
	sRestriction = sRestriction + CH_LEFTPAREN;

	if empty(list_object:'Start Date') then
		sRestrict = physicalname('Last Contact Date' of table(list_object:'Table Reference')) + CH_LESSTHAN + CH_EQUAL + CH_SPACE + CH_SINGLEQUOTE + sqlDate(list_object:'End Date') + CH_SINGLEQUOTE;
	elseif empty(list_object:'End Date') then
		sRestrict = physicalname('Last Contact Date' of table(list_object:'Table Reference')) + CH_GREATERTHAN + CH_EQUAL + CH_SPACE + CH_SINGLEQUOTE + sqlDate(list_object:'Start Date') + CH_SINGLEQUOTE;
	else
		sRestrict = physicalname('Last Contact Date' of table(list_object:'Table Reference')) + CH_LESSTHAN + CH_EQUAL + CH_SPACE + CH_SINGLEQUOTE + sqlDate(list_object:'End Date') + CH_SINGLEQUOTE + CH_SPACE + SQL_AND + CH_SPACE + physicalname('Last Contact Date' of table(list_object:'Table Reference')) + CH_GREATERTHAN + CH_EQUAL + CH_SPACE + CH_SINGLEQUOTE + sqlDate(list_object:'Start Date') + CH_SINGLEQUOTE;
	end if;
	sRestriction = sRestriction + sRestrict;

	sRestriction = sRestriction + CH_RIGHTPAREN;
end if;

{Apply any range restrictions based on the Find text the user entered}
if not empty(list_object:'Find Text') then
	if not empty(sRestriction) then
		sRestriction = sRestriction + CH_SPACE + SQL_AND + CH_SPACE;
	end if;

	sRestriction = sRestriction + CH_LEFTPAREN;
	sFind_SQL = SQL_FormatStrings(CH_PERCENT + list_object:'Find Text' + CH_PERCENT);

	sRestrict = physicalname('Customer Number' of table ContactHistoryTrxTemp) + CH_SPACE + SQL_LIKE + CH_SPACE + sFind_SQL;
	sRestriction = sRestriction + CH_SPACE + sRestrict;

	sRestrict = physicalname('Customer Name' of table ContactHistoryTrxTemp) + CH_SPACE + SQL_LIKE + CH_SPACE + sFind_SQL;
	sRestriction = sRestriction + CH_SPACE + SQL_OR + CH_SPACE + sRestrict;

	sRestrict = physicalname('First Contact Date' of table ContactHistoryTrxTemp) + CH_SPACE + SQL_LIKE + CH_SPACE + sFind_SQL;
	sRestriction = sRestriction + CH_SPACE + SQL_OR + CH_SPACE + sRestrict;

	sRestrict = physicalname('Contact Salesperson ID' of table ContactHistoryTrxTemp) + CH_SPACE + SQL_LIKE + CH_SPACE + sFind_SQL;
	sRestriction = sRestriction + CH_SPACE + SQL_OR + CH_SPACE + sRestrict;

	sRestrict = physicalname('Last Contact Date' of table ContactHistoryTrxTemp) + CH_SPACE + SQL_LIKE + CH_SPACE + sFind_SQL;
	sRestriction = sRestriction + CH_SPACE + SQL_OR + CH_SPACE + sRestrict;

	sRestrict = physicalname('Contact Salesperson ID 2' of table ContactHistoryTrxTemp) + CH_SPACE + SQL_LIKE + CH_SPACE + sFind_SQL;
	sRestriction = sRestriction + CH_SPACE + SQL_OR + CH_SPACE + sRestrict;

	sRestriction = sRestriction + CH_RIGHTPAREN;
end if;

range table(list_object:'Table Reference') where sRestriction;


Documentation Feedback