MS Dynamics Great Plains: Built-in Macro System
All related posts: Reference Page – GP/QTP Automation
Documentation
Microsoft Dynamics Great Plains Dexterity Programmer’s Guide: http://mbs.microsoft.com/downloads/public/GP90Docs/Prgv2.pdf
Refer to “Part 7: Software Engineering, Chapter 34: “Testing Your Application”.
Microsoft Dynamics Great Plains DexterityMacro System in “Recording Test Cases” document: http://www.microsoft.com/downloads/details.aspx?FamilyID=7544609d-425a-4dfb-a5be-0937d8a63c50
Application setup
The following configuration changes have to be made to fully enable Dexterity Macro support.
1. Dex.ini file
Locate this file in “./Data” subfolder.
Add the following line:
ShowAdvancedMacroMenu=TRUE
This will enable “Tools/Macro/Advanced” submenu.
2. Execution Log folder
Dexterity Macro produces all the output to text file.
Make sure you define log file by adding the following line in your macros:
Logging file ‘:c:GP/Log/maclog.txt’
Note that non-windows syntax is used defining the path.
For the full list of available options refer to “Setting up the Microsoft Dynamics GP Environment” paragraph in “Recording Test Cases” document.
Available macro commands
CommandExec
ClearAllVars
ClearVar
IfDefined…EndIf
IfNotDefined…EndIf
SetVar
TNT_Event
Macros
DField
DWin
DumpField
DumpFieldBegin…DumpFieldEnd
DMenu
DMenuAll
Logging
Pause
MenuSelect
FileOpen
FileSave
FileSaveAs
PrintDialog
OpenForm
ScrollByLine
ScrollByPage
ScrollToEnd
TransLinePrepare
ActivateWindow
CheckActiveWin
CloseWindow
NewActiveWin
WindowMove
WindowSize
CheckFocusSpring
ClickCancel
ClickHit
ClickHitMS
ColSortAsc
ColSortDes
ContNatTypeTo
ContTypeTo
DoubleClickHit
MoveTo
NatTypeTo
SelChanged
SelectAccel
SelectChars
StateClick
ToggleNode
TypeTo
Commands I used
Macro command | Description |
Logging | Specify output log file. If not specified the all macro run-time messages will be displayed in dialog boxes. |
DWin | Capture screenprint (picture) of the window. Window must be active.Example. DWin dictionary ‘default’ form ‘PM_Vendor_Maintenance’ window ‘PM_Vendor_Maintenance’ file ‘../WDump1.pcx’ |
DumpFieldBegin DumpField … DumpField … DumpField …DumpFieldEnd | Capture names and text values of specified fields. Window must be active.Example.DumpFieldBegin dictionary ‘default’ form ‘PM_Vendor_Maintenance’ window ‘PM_Vendor_Maintenance’ file ‘../SFDump1.txt’DumpField field ‘Vendor ID’DumpField field ‘Vendor Name’DumpFieldEndOutput format: “field name” : “field value”. |
ActivateWindow | Makes opened window active and sets context focus on it.Example.ActivateWindow dictionary ‘default’ form ‘PM_Vendor_Maintenance’ window ‘PM_Vendor_Maintenance’ |
CloseWindow | Closes opened window.Example.CloseWindow dictionary ‘default’ form ‘PM_Vendor_Maintenance’ window ‘PM_Vendor_Maintenance’ |
NewActiveWin | Sets context focus on a window. Note: it doesn’t open or activate a window.Example.NewActiveWin dictionary ‘default’ form ‘PM_Vendor_Maintenance’ window ‘PM_Vendor_Maintenance’ |
MoveTo | Sets focus on a field. The field should exist within the context of active window. Note: moving/removing focus might trigger certain event handlers so always move focus to a field before acting with it, and always move away focus from the last input field.Example. MoveTo field ‘OK Button’ |
ClickHit | Left-click on a field. The field should exist within the context of active window.Example. ClickHit field ‘OK Button’ |
StateClick | Left-click on a “state” type field (check box, radio button). Toggles state of the field. The field should exist within the context of active window.Example. StateClick field ‘Active’ |
TypeTo | Type in text to a field (text box, composite box). The field should exist within the context of active window. Note. For a composite type fields each input section is operated separately.Example. TypeTo field ‘Account Description’Composite box example.MoveTo field ‘Account Number CS’:’Account_Segment_Pool1’TypeTo field ‘Account Number CS’:’Account_Segment_Pool1′ , ‘111’MoveTo field ‘Account Number CS’:’Account_Segment_Pool2’TypeTo field ‘Account Number CS’:’Account_Segment_Pool2′ , ‘222’ |
Identified Issues
1) No parameterization
Dexterity Macro is GUI interaction oriented language. It does not support data retrieval operations like reading from a file. Therefore, all values are hard-coded.
The one possible solution is to generate macro command file dynamically in the run-time by using predefined template. Master code (i.e. VBScript in QTP) substitutes values by finding tokens contained in a template.
2) Synchronization issues
A recorded script almost never works. Every command expects GUI to be available immediately and in case of failure execution immediately stops.
Recorded scripts should be modified manually with the following recommendations.
Window synchronization
Close windows you no longer need. Save or discard before closing.
Use NewActiveWin in pair with ActivateWindow. If “window is not active” error still occurred use multiple ActivateWindow lines. Each line adds an approximately 1 second synchronization.
Example.
NewActiveWin dictionary ‘default’ form ‘PM_Vendor_Maintenance’ window ‘PM_Vendor_Maintenance’
ActivateWindow dictionary ‘default’ form ‘PM_Vendor_Maintenance’ window ‘PM_Vendor_Maintenance’
ActivateWindow dictionary ‘default’ form ‘PM_Vendor_Maintenance’ window ‘PM_Vendor_Maintenance’
ActivateWindow dictionary ‘default’ form ‘PM_Vendor_Maintenance’ window ‘PM_Vendor_Maintenance’
Field synchronization
Use MoveTo command before interacting with a field. Duplicate this line to add synchronization.
Combine it with ActivateWindow command.
Move focus to buttons to trigger event handlers in text boxes you previously populated.
2 responses to "MS Dynamics Great Plains: Built-in Macro System"
In GP2010, i have this macro i recorded who make Cut&paste :
# DEXVERSION=11.00.0359.000 2 2
CheckActiveWin dictionary ‘Canadian Payroll’ form ‘P_CPY_SETP_ROE’ window ‘P_CPY_ROE_Amounts’
MoveTo field ‘P_ROE_PP_Amount'[26]
CommandExec form BuiLtin command cmdEditCopy
MoveTo field ‘P_ROE_PP_Amount'[27]
CommandExec form BuiLtin command cmdEditPaste
When i run it i get the message :
Command disabled (Line #4)
This line #4 is « CommandExec form BuiLtin command cmdEditCopy »
You know why?
[ Albert’s reply. That could be for a number of reasons; you need to do a hands-on investigation.
First, try to use another built-in command to see if all of them or only this particular one doesn’t work.
Second, see if the GUI is in the right context state for copying of record of employment amount.
As a workaround you can try TypeTo command to directly send Ctrl-C / Ctrl-V keystrokes.]
Looking to better understand how to make macros respond properly when there is a possibility of a popup box and when there is not – say for example “Do you want to roll this down?”
This doesnt happen in every cycle and I see IFDefined but I cannot figure out how to use that. Can anyone help me with this? How to trap when errors will otherwise occur when there is no window to set focus on.
Thanks