Adding Report List items

When a Report List is displayed, a temporary table is built that contains the reports to display for that list. To have your reports added to the temporary table, create a procedure trigger for the LoadData procedure of the syReportList form.

The following example is a portion of the Startup script for the sample integrating application. It registers a procedure trigger that will add items to the Sales Report List for the sample.

l_result = Trigger_RegisterProcedure(script LoadData of form syReportList, TRIGGER_AFTER_ORIGINAL, script IG_ReportList_AddReports);
if l_result <> SY_NOERR then
	warning "Procedure trigger registration failed.";
end if;

Determining whether to add reports

The processing procedure that runs in response to this trigger must use the parameters passed into the procedure to determine whether the reports should be added for the Report List the user is displaying. You should add your reports in the following cases:

Specifying information about each report

The syReportData composite contains all of the information about each report that will be added to the Report List. You will set the values in this composite, based on the type of report you’re adding to the list. Refer to Composite definitions for a description of this composite.

The following table lists the types of reports that can be added, and indicates which components of the syReportData composite must be set. The Xs indicate required values, and the Os indicate optional values for each type. Some components of the composite are used internally by the Report List implementation, and should not be set.

[spacer]

 

Simple

Report with Options

Report from Window

SmartList Favorite

SQL Reporting

External

Other

Report Type

X

X

X

X

X

X

X

Product ID

X

X

X

X

X

X

X

Report Series DictID

X

X

X

 

X

X

X

Report Series ID

X

X

X

 

X

X

X

Report Category ID

O

O

O

 

O

O

O

Report ID

X

X

X

X

X

X

X

Report Option ID

 

X

 

 

 

 

 

Report Option Name

 

X

 

O

 

 

 

My Report Name

 

O

 

 

 

 

 

VisibleTo

 

 

 

O

 

 

 

User ID

 

 

 

O

 

 

 

User Class

 

 

 

O

 

 

 

Company ID

 

 

 

O

 

 

 

String A 255

O

O

O

 

O

O

O

Report Options Table Ref

 

O

 

 

 

 

 

Report Names Table Ref

 

O

 

 

 

 

 

DictID

X

X

X

 

 

 

 

Resid

X

X

X

 

 

 

 


Adding each report

When the syReportData composite has been supplied with the appropriate data, the AddReport() function of the syReportList form is used to add the report to the list.

When adding a report that uses a report options window, you will be using the AddReport() function several times. The first time adds the template report entry, with the report option name “<<New>>”. This entry in the Report List opens the report options window for the report so the user can create a new report option. Next, your code should loop through every report option that has been defined for the report, and add an entry to the Report List.

When adding an item for SmartList favorites, you must supply the ASI_Favorite_Type for the Report ID component of the syReportData composite. The Report List will automatically add all of the SmartList favorites of that type for the current user logged into Microsoft Dynamics GP. If you specify the name of a specific favorite in the Report Option Name component, only that item will be added to the Report List.

Example

The following example shows the trigger processing procedure for the sample integrating application that adds the various report types to the Sales Report List. Notice how the reports are added to the predefined Sales report series. Also note how only the SmartList favorites are added when the SmartList Favorites Report List is being displayed.

in ListObjState list_object;
in 'Report Series DictID' nSeriesDictID;
in 'Report Series ID' nSeriesID;

local integer status;
local syReportData RptData;

{Add items to the Sales series or if all reports are being requested}
if (nSeriesID = REPORTS_ALL of form syReportList) or ((nSeriesDictID = DYNAMICS) and (nSeriesID = REPORTSERIES_SALES)) then

	{Simple Report}
	clear field RptData;
	RptData:'Report Type' = REPORTTYPE_SIMPLE;
	RptData:'Product ID' = IG_PROD_ID;
	RptData:'Report Series DictID' = DYNAMICS;
	RptData:'Report Series ID' = REPORTSERIES_SALES;
	RptData:'Report ID' = ReptID_LeadsSimple;
	RptData:'Report Option Name' = "Leads";
	RptData:'DictID' = IG_PROD_ID;
	RptData:'Resid' = resourceid(report IG_Leads);

	status = AddReport(RptData) of form syReportList;

	{Reports with Options}
	{First, add the <<New>> entry for the report.}
	clear field RptData;
	RptData:'Report Type' = REPORTTYPE_RPTWITHOPTIONS;
	RptData:'Product ID' = IG_PROD_ID;
	RptData:'Report Series DictID' = DYNAMICS;
	RptData:'Report Series ID' = REPORTSERIES_SALES;
	RptData:'Report ID' = ReptID_LeadsWithOptions;
	RptData:'Report Option ID' = 0;
	RptData:'Report Option Name' = getmsg(7487); {<<New>>}
	RptData:'DictID' = IG_PROD_ID;
	RptData:'Resid' = resourceid(report IG_Leads);
	
	status = AddReport(RptData) of form syReportList;

	{Then add an entry for each option that has been defined.}
	range clear table IG_Leads_ROPT;
	'Report ID' of table IG_Leads_ROPT = ReptID_LeadsWithOptions;
	clear 'Report Option Name' of table IG_Leads_ROPT;
	range start table IG_Leads_ROPT by number 1;
	fill 'Report Option Name' of table IG_Leads_ROPT;
	range end table IG_Leads_ROPT by number 1;

	get first table IG_Leads_ROPT;
	while err() = OKAY do
		clear field RptData;
		RptData:'Report Type' = REPORTTYPE_RPTWITHOPTIONS;
		RptData:'Product ID' = IG_PROD_ID;
		RptData:'Report Series DictID' = DYNAMICS;
		RptData:'Report Series ID' = REPORTSERIES_SALES;
		RptData:'Report ID' = ReptID_LeadsWithOptions;
		RptData:'Report Option ID' = 'Report ID' of table IG_Leads_ROPT;
		RptData:'Report Option Name' = 'Report Option Name' of table IG_Leads_ROPT;
		RptData:'DictID' = IG_PROD_ID;
		RptData:'Resid' = resourceid(report IG_Leads);
	
		status = AddReport(RptData) of form syReportList;

		get next table IG_Leads_ROPT;
	end while;
	range clear table IG_Leads_ROPT;

	{First, add the <<New>> entry for the report.}
	clear field RptData;
	RptData:'Report Type' = REPORTTYPE_RPTWITHOPTIONS;
	RptData:'Product ID' = IG_PROD_ID;
	RptData:'Report Series DictID' = DYNAMICS;
	RptData:'Report Series ID' = REPORTSERIES_SALES;
	RptData:'Report ID' = ReptID_LeadsList;
	RptData:'Report Option ID' = 0;
	RptData:'Report Option Name' = getmsg(7487); {<<New>>}
	RptData:'DictID' = IG_PROD_ID;
	RptData:'Resid' = resourceid(report IG_Leads);
	
	status = AddReport(RptData) of form syReportList;

	{Then add an entry for each option that has been defined.}
	range clear table IG_Leads_ROPT;
	'Report ID' of table IG_Leads_ROPT = ReptID_LeadsList;
	clear 'Report Option Name' of table IG_Leads_ROPT;
	range start table IG_Leads_ROPT by number 1;
	fill 'Report Option Name' of table IG_Leads_ROPT;
	range end table IG_Leads_ROPT by number 1;

	get first table IG_Leads_ROPT;
	while err() = OKAY do
		clear field RptData;
		RptData:'Report Type' = REPORTTYPE_RPTWITHOPTIONS;
		RptData:'Product ID' = IG_PROD_ID;
		RptData:'Report Series DictID' = DYNAMICS;
		RptData:'Report Series ID' = REPORTSERIES_SALES;
		RptData:'Report ID' = ReptID_LeadsList;
		RptData:'Report Option ID' = 'Report ID' of table IG_Leads_ROPT;
		RptData:'Report Option Name' = 'Report Option Name' of table IG_Leads_ROPT;
		RptData:'DictID' = IG_PROD_ID;
		RptData:'Resid' = resourceid(report IG_Leads);

		status = AddReport(RptData) of form syReportList;

		get next table IG_Leads_ROPT;
	end while;
	range clear table IG_Leads_ROPT;

	{Other Report Type}
	clear field RptData;
	RptData:'Report Type' = REPORTTYPE_OTHER;
	RptData:'Product ID' = IG_PROD_ID;
	RptData:'Report Series DictID' = DYNAMICS;
	RptData:'Report Series ID' = REPORTSERIES_SALES;
	RptData:'Report ID' = ReptID_LeadsQuick;

	status = AddReport(RptData) of form syReportList;

	{SmartList Favorite}
	clear field RptData;
	RptData:'Report Type' = REPORTTYPE_SMARTLISTFAVORITE;
	RptData:'Product ID' = IG_PROD_ID;
	RptData:'Report Series DictID' = DYNAMICS;
	RptData:'Report Series ID' = REPORTSERIES_SALES;
	RptData:'Report ID' = SMARTLIST_OBJECTTYPE_LEADS;
	RptData:'Report Option Name' = "";
	RptData:'VisibleTo' = SMARTLIST_VISIBLETO_SYSTEM; {All users}

	status = AddReport(RptData) of form syReportList;

	{Report from Window}
	clear field RptData;
	RptData:'Report Type' = REPORTTYPE_RPTFROMWINDOW;
	RptData:'Product ID' = IG_PROD_ID;
	RptData:'Report Series DictID' = DYNAMICS;
	RptData:'Report Series ID' = REPORTSERIES_SALES;
	RptData:'Report ID' = ReptID_ContactHistory;
	RptData:'DictID' = IG_PROD_ID;
	RptData:'Resid' = resourceid(form IG_Contact_History);

	status = AddReport(RptData) of form syReportList;

end if;

{Only SmartList favorites are being displayed}
if (nSeriesID = REPORTS_SMARTLISTONLY of form syReportList) then

	{SmartList Favorite}
	clear field RptData;
	RptData:'Report Type' = REPORTTYPE_SMARTLISTFAVORITE;
	RptData:'Product ID' = IG_PROD_ID;
	RptData:'Report Series DictID' = DYNAMICS;
	RptData:'Report Series ID' = REPORTSERIES_SALES;
	RptData:'Report ID' = SMARTLIST_OBJECTTYPE_LEADS;
	RptData:'Report Option Name' = "";
	RptData:'VisibleTo' = SMARTLIST_VISIBLETO_SYSTEM; {All users}

	status = AddReport(RptData) of form syReportList;

end if;


Documentation Feedback