#Dexterity Automating or Customizing the Report Destination Window


David Meego - Click for blog homepageBack in 2009, I posted about Automating or Customizing the Report Destination Window. In that article I discussed that there is more than one version of the Report Destination dialog and that additional methods would be required to control the version that is in the Dexterity Runtime Engine.

This article gets into more detail showing how the control the different dialogs with Dexterity.

There are now three versions of the Report Destination dialog with the addition an extra version in the Dexterity Runtime Engine that has been designed to work with emailing.

The example code provided below is designed to dismiss each of the three dialogs. It uses the Window Activate event because this event is triggered after the window is opened and any initialization scripts have been completed. Once the window gains focus, the Window Activate event is fired and the trigger handler code “clicks” the Cancel button.

Controlling the Report Destination dialogs in the runtime engine is not possible using VBA (Visual Basic for Applications) or Visual Studio Tools as they cannot access the runtime engine resources. One method that has worked in the past is creating and running a macro file to “press” the Cancel button, but this method cannot work on the web client and is not as reliable.

To control the dialogs in the Dexterity Runtime Engine (DEX.DIC) we can use Cross Dictionary techniques against Dictionary ID 1. While not listed in the Dynamics.set launch file, the runtime engine is still accessible as Product ID 1. This means that the trigger is registered using the Trigger_RegisterFocusByName() command and the handler code uses the execute() command.

Below are the three trigger handler scripts and an excerpt of the Startup script with the trigger registrations:

WDC_Dynamics_Report_Destination_WIN_ACT

if not 'WDC Dismiss Report Destination' of globals then
	abort script;
end if;

if isopen(form 'Report_Destination') then
	run script 'Cancel Button' of window 'Report_Destination' of form 'Report_Destination';
end if;

WDC_Dex_Report_Ask_WIN_ACT

local text code;
local string compiler_error;

if not 'WDC Dismiss Report Destination' of globals then
	abort script;
end if;

pragma(disable warning LiteralStringUsed);

clear code;
code = code + "if isopen(form 'Report Ask') then" + char(13);
code = code + "	run script '(L) Cancel' of window 'Report Type' of form 'Report Ask';" + char(13);
code = code + "end if;" + char(13);

pragma(enable warning LiteralStringUsed);

if execute(1{DEX.DIC}, code, compiler_error) <> 0 then
	error compiler_error;
end if;

WDC_Dex_Report_Destination_WIN_ACT

local text code;
local string compiler_error;

if not 'WDC Dismiss Report Destination' of globals then
	abort script;
end if;

pragma(disable warning LiteralStringUsed);

clear code;
code = code + "if isopen(form 'Report Destination') then" + char(13);
code = code + "	run script '(L) Cancel' of window 'Report Type' of form 'Report Destination';" + char(13);
code = code + "end if;" + char(13);

pragma(enable warning LiteralStringUsed);

if execute(1{DEX.DIC}, code, compiler_error) <> 0 then
	error compiler_error;
end if;

Startup (excerpt)

pragma(disable warning LiteralStringUsed);

if Trigger_RegisterFocus(window 'Report_Destination' of form 'Report_Destination', TRIGGER_FOCUS_ACTIVATE, TRIGGER_AFTER_ORIGINAL, script WDC_Dynamics_Report_Destination_WIN_ACT) <> SY_NOERR then
	warning "Window Report_Destination of form Report_Destination focus activate trigger registration failed.";
end if;

if Trigger_RegisterFocusByName(1 {DEX.DIC}, "window 'Report Type' of form 'Report Ask'", TRIGGER_FOCUS_ACTIVATE, TRIGGER_AFTER_ORIGINAL, script WDC_Dex_Report_Ask_WIN_ACT) <> SY_NOERR then
	warning "Window Report Type of form Report Ask focus activate trigger registration failed.";
end if;

if Trigger_RegisterFocusByName(1 {DEX.DIC}, "window 'Report Type' of form 'Report Destination'", TRIGGER_FOCUS_ACTIVATE, TRIGGER_AFTER_ORIGINAL, script WDC_Dex_Report_Destination_WIN_ACT) <> SY_NOERR then
	warning "Window Report Type of form Report Destination focus activate trigger registration failed.";
end if;

pragma(enable warning LiteralStringUsed);

You will notice that the trigger handlers check a ‘WDC Dismiss Report Destination’ of globals system variable to ensure that it only automatically dismisses the dialogs when desired and not all of the time.

Hope you find this information useful.

David

PS: Stay tuned for how you can use GP Power Tools to achieve the same results without needing any other external tools or development environments.

This article was originally posted on http://www.winthropdc.com/blog.

One thought on “#Dexterity Automating or Customizing the Report Destination Window

Please post feedback or comments

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.