Retrieving records for the SmartList

Another procedure for your integration will manually retrieve the records that will be displayed for the new SmartList object. This procedure will be used when all records for the object type are to be displayed, and no search criteria has been specified. It will also be used when search criteria have been supplied, but you have chosen not to use the SQL-optimized search built into SmartList.

This procedure sets the SmartList_Master_ID global variable that was described in Retrieving column values.


This procedure will also be called when the SmartList object is used with a reminder in Microsoft Dynamics GP. When you create a SmartList favorite, it can also be saved as a reminder that appears on the home page. When used for a reminder, a summary containing the total number of records, or the total of the values of a specific column is returned from the procedure. When the summary is being generated, the user stop action and the maximum number of records setting for the SmartList query are ignored. This ensures that all records in the table are examined for the summary.

As an example, the following is the SmartList_GetLeadRecords procedure that is defined for the sample integrating application. It is called by the Explorer_Get_Records_Background procedure to add Leads items to the SmartList.

Procedure name: SmartList_GetLeadRecords

 

in integer IN_Total_SubItems;
in Explorer_BOOL_List IN_Searching;
in Explorer_Resource_List IN_Dict_List;
in Explorer_Resource_List IN_Field_List;
in Explorer_INT_List IN_Field_Dict_ID;
in Explorer_INT_List IN_Field;
in Explorer_INT_List IN_Datatype;
in Explorer_INT_List IN_Type;
in Explorer_STR30_List IN_Search_From;
in Explorer_STR30_List IN_Search_To;
in Explorer_BOOL_List IN_Match_Case;
in integer IN_Global_Search_Type;
in Explorer_Field_Comparison IN_Field_Comparison;
in Explorer_Start_Comp_Field_ID IN_Start_Comp_Field_ID;
in Explorer_Start_Comp_Field_Dict IN_Start_Comp_Field_Dict;
in Explorer_End_Comp_Field_ID IN_End_Comp_Field_ID;
in Explorer_End_Comp_Field_Dict IN_End_Comp_Field_Dict;

inout long IO_Max_Records;

in boolean IN_GetSummary;
in integer IN_Summary_Type; {0 = Number of records, 1 = Total of Column}
inout long IO_SummaryCount;
in integer IN_nSummaryFieldDictID;
in integer IN_nSummaryFieldID;
inout currency IO_ColumnTotal;

local boolean b_Stop, b_Found;
local long l_Record_Count,SQL_Context;
local integer l_Key,Error;

local currency IO_Currency;
local string IO_String;
local integer IO_Datatype;
local long IO_Long;
local date IO_Date;
local time IO_Time;

{This block of code will be run only if the Explorer_Optimize_For_SQL procedure returns false}
if 'SQL Server' of globals > 0 and (IN_Searching[1] or IN_Searching[2] or IN_Searching[3] or IN_Searching[4]) then
	call with name "Explorer_SQL_Search_Generic" in dictionary SMARTLIST,
		IG_PROD_ID,
		SMARTLIST_OBJECTTYPE_LEADS,
		IN_Searching,
		IN_Field_Dict_ID,
		IN_Field, 
		IN_Datatype, 
		IN_Type, 
		IN_Search_From, 
		IN_Search_To, 
		IN_Match_Case,
		IN_Field_Comparison,
		IN_Start_Comp_Field_ID,
		IN_Start_Comp_Field_Dict,
		IN_End_Comp_Field_ID,
		IN_End_Comp_Field_Dict,
		IN_Global_Search_Type, 
		SQL_Context,
		Error,
		IN_GetSummary,
		IN_Summary_Type,
		IO_SummaryCount,
		IN_nSummaryFieldDictID,
		IN_nSummaryFieldID,
		IO_ColumnTotal;

	{If Error returns -1, then a sequential search should be used}
	if Error = OKAY then
		call Explorer_Process_SQL_Data, IG_PROD_ID, SMARTLIST_OBJECTTYPE_LEADS, IN_Total_SubItems, IN_Dict_List, IN_Field_List, IO_Max_Records, SQL_Context;
		abort script;
	end if;
end if;

{This is the traditional SmartList code that works for all database types}

set l_Record_Count to 0;
set l_Key to 1;
call with name "Explorer_Check_Stop_Processing" in dictionary SMARTLIST, b_Stop;

{ Loop through table to get records }
get first table IG_Leads_MSTR by number l_Key;
while err() <> EOF do

	{Check for additional exit criteria when a standard request is performed.}
	{These checks are not done when a summary is being performed.}
	if IN_GetSummary = false then

		{ Was the maximum number of records exceeded? }
		if l_Record_Count >= IO_Max_Records then
			exit while;
		end if;

		{ Was Stop chosen? }
		if b_Stop = true then
			exit while;
		end if;
	end if;

	{Set the global SmartList Master ID}
	SmartList_Master_ID of globals = 'Lead ID' of table IG_Leads_MSTR;

	call with name "Explorer_Search_Generic" in dictionary SMARTLIST,
		IG_PROD_ID,
		SMARTLIST_OBJECTTYPE_LEADS,
		IN_Searching,
		IN_Field_Dict_ID,
		IN_Field,
		IN_Datatype,
		IN_Type,
		IN_Search_From,
		IN_Search_To,
		IN_Match_Case,
		IN_Global_Search_Type,

		IN_Field_Comparison, 
		IN_Start_Comp_Field_ID, 
		IN_Start_Comp_Field_Dict,
		IN_End_Comp_Field_ID,
		IN_End_Comp_Field_Dict,
		b_Found;

	if b_Found then
		increment l_Record_Count;

		{ Is a summary being requested? }
		if IN_GetSummary = false then
			{ No summary is being requested }
			call foreground SmartList_Leads_FillOneRowAtTime,
				IN_Total_SubItems,
				IN_Dict_List,
				IN_Field_List,
				l_Record_Count,
				table IG_Leads_MSTR;
		else
			{ A summary is being requested. Return data based on the summary
				type requested. }
			if IN_Summary_Type = 0 then 
				{ Total number of records is requested }
				increment IO_SummaryCount;
			end if;

			if IN_Summary_Type = 1 then
				{ A total is being requested for the specified field }
				clear IO_Currency;

				call Explorer_Get_Field_As_String_From_Table,
					IO_String,
					IG_PROD_ID,
					SMARTLIST_OBJECTTYPE_LEADS,
					IN_nSummaryFieldDictID,
					IN_nSummaryFieldID,
					(IN_Searching[1] or IN_Searching[2] or IN_Searching[3] or IN_Searching[4]),
					'Lead ID' of table IG_Leads_MSTR,
					IO_Datatype,
					IO_Long,
					IO_Date,
					IO_Currency,
					IO_Time;

				{ Increase the total by the returned currency amount }
				IO_ColumnTotal = IO_ColumnTotal + IO_Currency;
			end if;
		end if;
	end if;

	get next table IG_Leads_MSTR by number l_Key;
	call with name "Explorer_Check_Stop_Processing" in dictionary SMARTLIST, b_Stop;
end while;


Documentation Feedback