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 Leads 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 Leads 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('Lead ID' of table(list_object:'Table Reference')) then sCommand = sCommand + CH_COMMA + "'Lead ID'" + " 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, or any search restrictions they have 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 Leads list. It creates a set of range selection criteria based on the user’s predefined selection 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'); {Qualified Leads only restriction } if list_object:ListOptionValue = LISTOPTION_LEADSQUALIFIED then sRestriction = physicalname('Qualified Lead' of table IG_Leads_MSTR) + CH_EQUAL + str(2); 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('Lead ID' of table IG_Leads_MSTR) + CH_SPACE + SQL_LIKE + CH_SPACE + sFind_SQL; sRestriction = sRestriction + CH_SPACE + sRestrict; sRestrict = physicalname('Lead Name' of table IG_Leads_MSTR) + CH_SPACE + SQL_LIKE + CH_SPACE + sFind_SQL; sRestriction = sRestriction + CH_SPACE + SQL_OR + CH_SPACE + sRestrict; sRestrict = physicalname('Address 1' of table IG_Leads_MSTR) + CH_SPACE + SQL_LIKE + CH_SPACE + sFind_SQL; sRestriction = sRestriction + CH_SPACE + SQL_OR + CH_SPACE + sRestrict; sRestrict = physicalname('Address 2' of table IG_Leads_MSTR) + CH_SPACE + SQL_LIKE + CH_SPACE + sFind_SQL; sRestriction = sRestriction + CH_SPACE + SQL_OR + CH_SPACE + sRestrict; sRestrict = physicalname('City' of table IG_Leads_MSTR) + CH_SPACE + SQL_LIKE + CH_SPACE + sFind_SQL; sRestriction = sRestriction + CH_SPACE + SQL_OR + CH_SPACE + sRestrict; sRestrict = physicalname('State' of table IG_Leads_MSTR) + CH_SPACE + SQL_LIKE + CH_SPACE + sFind_SQL; sRestriction = sRestriction + CH_SPACE + SQL_OR + CH_SPACE + sRestrict; sRestrict = physicalname('Zip' of table IG_Leads_MSTR) + CH_SPACE + SQL_LIKE + CH_SPACE + sFind_SQL; sRestriction = sRestriction + CH_SPACE + SQL_OR + CH_SPACE + sRestrict; sRestrict = physicalname('Contact' of table IG_Leads_MSTR) + CH_SPACE + SQL_LIKE + CH_SPACE + sFind_SQL; sRestriction = sRestriction + CH_SPACE + SQL_OR + CH_SPACE + sRestrict; sRestrict = physicalname('Lead Business Category' of table IG_Leads_MSTR) + CH_SPACE + SQL_LIKE + CH_SPACE + sFind_SQL; sRestriction = sRestriction + CH_SPACE + SQL_OR + CH_SPACE + sRestrict; sRestrict = physicalname('Potential Revenue' of table IG_Leads_MSTR) + CH_SPACE + SQL_LIKE + CH_SPACE + sFind_SQL; sRestriction = sRestriction + CH_SPACE + SQL_OR + CH_SPACE + sRestrict; sRestrict = physicalname('Phone 1' of table IG_Leads_MSTR) + CH_SPACE + SQL_LIKE + CH_SPACE + sFind_SQL; sRestriction = sRestriction + CH_SPACE + SQL_OR + CH_SPACE + sRestrict; sRestrict = physicalname('Phone 2' of table IG_Leads_MSTR) + CH_SPACE + SQL_LIKE + CH_SPACE + sFind_SQL; sRestriction = sRestriction + CH_SPACE + SQL_OR + CH_SPACE + sRestrict; sRestrict = physicalname('Fax' of table IG_Leads_MSTR) + CH_SPACE + SQL_LIKE + CH_SPACE + sFind_SQL; sRestriction = sRestriction + CH_SPACE + SQL_OR + CH_SPACE + sRestrict; sRestrict = physicalname('Lead Source' of table IG_Leads_MSTR) + 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;