Thursday, May 8, 2008

Macros in Microsoft Dynamics GP v 10.0

Yesterday, I was asked why macros that seemed pretty straight forward and worked well in previous releases of Microsoft Dynamics GP, all in a sudden, seem not to work in Dynamics GP 10. Case in particular, a macro was previously written to automate the checklinks of the Sales Work table group and automatically close the application after completing the operation, but now seemed to hung when attempting to close.

After running a few tests, as I suspected, the reason Microsoft Dynamics GP is not quiting is 3-fold:

1) The Navigation Pane feature is an internal Dexterity window. When control is returned from the check links process, the focus is immediately returned to the navigation pane, not the work area form (BuiLtin form), causing the macro command to fail.

To fix this, the navigation pane needs to be disabled first when the macro begins its execution:

CommandExec dictionary 'default' form 'Command_System' command NavigationPane

2) Macros and Progress Windows are enemies. This one is not new, however, it is a common occurrence since macros attempt to restore the focus to the progress window itself once the progress field vanishes (when it reaches 100%).

3) Report output to screen is also a point of failure for macros. The macro will need to bypass the screen output to a file if possible, since the Report output screen is an internal Dexterity window.

Saving to a file (appending always) will avoid trying to close the screen output window, hence cancelling interaction with the internal Dexterity form.

The following is the complete macro code:

CommandExec dictionary 'default' form 'Command_System' command NavigationPane
CommandExec dictionary 'default' form 'Command_System' command 'SY_Check_Links'
NewActiveWin dictionary 'default' form 'SY_Check_Links' window 'Check Links'
ClickHit field 'File Series' item 2 # 'Sales'
MoveTo field Source item 0
ClickHit field Source item 19 # 'Sales Work'
MoveTo field 'Insert>> Button I'
ClickHit field 'Insert>> Button I'
MoveTo field 'OK Button'
ClickHit field 'OK Button'
NewActiveWin dictionary 'default' form 'Report_Destination' window 'Report_Destination'
MoveTo field 'Print to File' # 'FALSE'
ClickHit field 'Print to File' # 'TRUE'
MoveTo field 'File Export Name'
TypeTo field 'File Export Name' , 'test.txt'
MoveTo field 'Export File Type' item 0
ClickHit field 'Export File Type' item 1 # 'Text file'

MoveTo field 'OK Button'
ClickHit field 'OK Button'
# NewActiveWin dictionary 'default' form sheLL window sheLL
# ActivateWindow dictionary 'default' form 'Progress_Control' window 'Progress_Window'
# NewActiveWin dictionary 'default' form sheLL window sheLL
# Print To File: 'File Maintenance Error Report'
CommandExec form BuiLtin command cmdQuitApplication

Highlighted in red are the key aspects that need to occur in the macro to bypass any user interaction and for the macro to be successful in its execution; note the exclusion of the Progress_Control window. Highlighted in orange is the bypass of the screen output in favor of a less interactive file export.

Hope this helps all of you who are trying to figure out this new Dynamics GP 10 user interface.

Please drop your comments about this article.

Mariano Gomez, MIS, MCP, PMP
Maximum Global Business, LLC


Anonymous said...

I am trying to run a batch file from the Navigation menu. Placing the Integration Group that I want to run is not working correctly. So I placed the Integration Group in a batch file and recorded the macro to click the Batch file. However, the macro is recording the integration steps. I don't want this. I would like to record all steps necessary to click the shortcut and let the batch file takeover from there. Any suggestions. Thanks.

Rommy Márquez said...

Hola Mariano, tengo una pregunta para usted (entiendo que habla español por eso escribo en este idioma que es mi lengua nativa). Debo usar la ventana de Entrada de Ensambles de GP y he creado una macro para ello, el problema que tengo es que en ciertas ocasiones no hay stock suficiente de alguna de las materias primas que componen el ensamble y en ese momento se abre la ventana con el mensaje de escasez, en nuestra empresa se permiten los inventarios en negativo por lo que aceptamos el paso de ensambles con esta condición, sin embargo, la macro en este punto se cae por que no tengo incluida esta condición y no puedo separar los ensambles con y sin stock para generar macros separadas.
Existe alguna posibilidad de incluir en la macro cual es el proceso que debe seguir si se abre la ventana de escasez y que de esta manera no se interrumpa el proceso de carga de los datos de la macro.
Espero poder contar con su ayuda.

ashish malwal said...

Hi i want to ask one thing can be record macros in great plains with windows 7 ?
if yes please tell me the way how we can record please

Dan Faustine said...

Has anyone actually tried these instructions in GP 2010? because I still can't get the application to close after implementing the code above... Can anyone advise?


Mariano Gomez said...


For GP2010 you will need to make a few changes.

The second line in your macro will need to be something like this:

Logging file none

The last line in your macro file will need to be something like this:

MenuSelect title File entry Exit