GP/QTP Automation: GUI Capture script for Dexterity Window

Posted by Albert Gareev on Oct 12, 2009 | Categories: Great PlainsSource code

A script capturing Dexterity objects (both GUI and non-GUI) contained within the window. Great Plains application is required to be up with the particular window invoked and activated.

All related posts: Reference Page – GP/QTP Automation  

Programming language and tool: VBScript / QTP. 

The script produces an output as XML file with the structure similar to QTP object repository.

Used resources:

GPHandle object class

GetDexActiveWindow macro.

Dynamics.Application classes.

Service Functions – XML (QTP, VBScript)

Library functions

Public Function GP_InitCOM()
   Dim boolRC

 boolRC = GPHandle.InitWrapper(<path to your VBA macro Excel file>)
 If Not boolRC Then
  Exit Function
 End If


End Function

Public Function GP_CloseCOM()
End Function


The script (put in a separate QTP Action)

Option Explicit
'Purpose: Capture and Map GUI of current (active) GP Dexterity Window into XML file
'Requirements: GP App started, required window is brought up
'DexWrapper.xls is properly set up
'Output: <window name>.xml

Dim boolRC
Dim objWindow, objWndField
Dim objRecord
Dim FieldIter
Dim objGPMapXML, objRoot, objFormMapXML, objWndMapXML, objFldMapXML
Dim objDesc, objProperty

boolRC = GP_InitCOM()
If Not boolRC Then
End If



Set objRecord = GPHandle.RetrieveParameters()

Set objWindow = GPHandle.GetDexWindowByName(objRecord.Item("Var1"), objRecord.Item("Var2"))
If objWindow is Nothing Then
End If

sGPMapXML = "<your output folder here e.g. c:\temp>" & "\" & objRecord.Item("Var4") &".xml"

Set objGPMapXML = XMLUtil.CreateXML("DexGUI")
Set objRoot = objGPMapXML.GetRootElement

Set objFormMapXML = CreateChildElementByName(objRoot, "Parent", "")
objFormMapXML.AddAttribute "name", objRecord.Item("Var1")
objFormMapXML.AddAttribute "class", "DexForm"
objFormMapXML.AddAttribute "childcount", "1"
Set objDesc = CreateChildElementByName(objFormMapXML, "desc", "")
Set objProperty = CreateChildElementByName(objDesc, "property", "")
objProperty.AddAttribute "name", "dexname"
objProperty.AddAttribute "value", objRecord.Item("Var1")
Set objWndMapXML = CreateChildElementByName(objFormMapXML, "Parent", "")
objWndMapXML.AddAttribute "name", objRecord.Item("Var2")
objWndMapXML.AddAttribute "class", "DexWindow"
objWndMapXML.AddAttribute "childcount", CStr(objWindow.CountFields())
Set objDesc = CreateChildElementByName(objWndMapXML, "desc", "")
Set objProperty = CreateChildElementByName(objDesc, "property", "")
objProperty.AddAttribute "name", "dexname"
objProperty.AddAttribute "value", objRecord.Item("Var2")

'Map fields
FieldIter = 1
Set objWndField = objWindow.GetFirstWindowField()

 If Not (objWndField is Nothing) Then
  Set objFldMapXML = CreateChildElementByName(objWndMapXML, "Object", "")
  objFldMapXML.AddAttribute "name", objWndField.GetName()
  objFldMapXML.AddAttribute "class", "DexObject"
  Set objDesc = CreateChildElementByName(objFldMapXML, "desc", "")
  Set objProperty = CreateChildElementByName(objDesc, "property", "")
  objProperty.AddAttribute "name", "dexname"
  objProperty.AddAttribute "value", objWndField.GetName()
  Set objProperty = CreateChildElementByName(objDesc, "property", "")
  objProperty.AddAttribute "name", "id"
  objProperty.AddAttribute "value", CStr(objWndField.GetID())
 End If

 FieldIter = FieldIter +1
 Set objWndField = objWindow.GetNextWindowField()

Loop While FieldIter <= objWindow.CountFields()

objGPMapXML.SaveFile sGPMapXML


Set objWindow  = Nothing
Set objWndField = Nothing
Set objGPMapXML = Nothing
Set objRoot = Nothing
Set objFormMapXML = Nothing
Set objWndMapXML = Nothing
Set objFldMapXML = Nothing

  • 6 responses to "GP/QTP Automation: GUI Capture script for Dexterity Window"

  • Tracy Lilyblade
    1st January 2010 at 14:32

    Happy New Years!! To my favorite blog, hopefully no tactical body armor is required with all those fools blasting their automatic weapons along busy streets.

    [ Albert’s comment. This one’s so funny, can’t resist to keep it. ]

  • Austin
    9th February 2010 at 9:37


    Thank you for a neat code! I use GUI Capture script and it works fine.
    Quick question though. I need to make a small change in xml file created without re-mapping a window. How can I manually get Dexterity GUI field names from GP?

    Appreciate your help, thanks.


    [ Albert’s reply.
    I emailed my answer a while ago.
    In addition to that I posted description with screenprints here. ]

  • Prasad
    12th August 2010 at 6:20

    Hi Sir,

    I am new to GP and please guide me how to start automate using QTP.

    Thanks in advance.

    Prasad G

    [ Albert’s reply.
    Hi, Prasad!

    I welcome you in this exciting journey.

    Dynamics Great Plains automation really IS a challenge, because the application has its own unique platform-independent GUI engine. That is – absolutely NO record/playback with QTP, TestComplete, or any other tool. And yet, as I discovered, GP is quite automation friendly, if you can do test automation through programming.

    I brought together all results of my investigations here. Off course, it’s not a ready-to-deploy commercial solution, but it has answers for all the steps to pass when building one. Should you have more questions don’t hesitate to ask them.

    Good luck! Albert ]

  • Prasad
    13th August 2010 at 4:30

    Hi Albert,

    I really appreciated your quick responce. I have gone through the link provided earlier but still not able to find the solution how to start. ( i am confused with XML, macros with exel etc….).

    It would be greatful if you provide help in considering one window in GP.

    Thanks in advance.


    [ Albert’s Reply.
    Hi, Prasad.

    If you just need to see one example of operating GUI inside a window, you can start with this one. If you want to start building automation on your own, you have to learn about technologies you’re going to use.

    From your reply (correct me if I’m wrong) I got the following:
    * you are not familiar with XML;
    * you are not familiar with Excel/VBA programming;
    * you have not come across Great Plains documentation on Dexterity Forms, GUI Macros, and back-end SanScript.

    With regards to XML, in my blog you can refer to related articles through this link. For starting with Excel/VB and VBScript, my compilation of links is here and here. All stuff, related to GP automation, is linked to the page I mentioned before.

    Hope this helps. Albert ]

  • Prasad
    18th August 2010 at 7:27

    Hi Albert,

    Thanks a lot.


  • TestGeek
    6th December 2010 at 9:39

    Thanks for the awesome idea. It saved MUCH time!

    [ Albert’s reply: you’re welcome. Don’t be shy to share some details :) ]

  • Leave a Reply

    * Required
    ** Your Email is never shared

Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported
This work by Albert Gareev is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported.