
Back 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.
[Ed] See new article on this topic:
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.
15-Aug-2022: Added link to #GPPT Automating or Customizing the Report Destination Window Revisited.
This article was originally posted on https://www.winthropdc.com/blog.
One thought on “#Dexterity Automating or Customizing the Report Destination Window”