GP/QTP Automation: GUI Mapping script

Posted by Albert Gareev on Sep 09, 2009 | Categories: Great PlainsSource code

All related posts: Reference Page – GP/QTP Automation  

Purpose: extract object descriptions from Dexterity Dictionary and create custom XML-based GUI Map file for QTP.

Used resources: Service Functions – XML (QTP, VBScript)

Option Explicit
' Purpose: Map GP Dexterity GUI into XML file
' Requirements: GP App started (don't have to login)
'Output: ".....\DexGUI.xml"

Dim GPApp, objForm, objWindow, objWndField
Dim sGPMapXML, sCurrentProduct
Dim FormIter, WinIter, FieldIter
Dim objGPMapXML, objRoot, objFormMapXML, objWndMapXML, objFldMapXML

Set GPApp = GetObject("", "Dynamics.Application")

sCurrentProduct = GPApp.CurrentProduct

'Define or parameterize your output folder here

sGPMapXML = "C:\TEMP\" & "\DexGUI.xml"
Set objGPMapXML = XMLUtil.CreateXML("DexGUI")
Set objRoot = objGPMapXML.GetRootElement

FormIter = 1
Set objForm = GPApp.GetFirstForm()
 If Not (objForm is Nothing) Then
  Set objFormMapXML = CreateChildElementByName(objRoot, "Form", "")
  objFormMapXML.AddAttribute "name", objForm.GetName()
  objFormMapXML.AddAttribute "childcount", CStr(objForm.CountWindows())
  WinIter = 1
  Set objWindow = objForm.GetFirstWindow()
   If Not (objWindow is Nothing) Then
    Set objWndMapXML = CreateChildElementByName(objFormMapXML, "Window", "")
    objWndMapXML.AddAttribute "name", objWindow.GetName()
    objWndMapXML.AddAttribute "childcount", CStr(objWindow.CountFields())
    FieldIter = 1
    Set objWndField = objWindow.GetFirstWindowField()
     If Not (objWndField is Nothing) Then
      Set objFldMapXML = CreateChildElementByName(objWndMapXML, "Field", "")
      objFldMapXML.AddAttribute "name", objWndField.GetName()
      objFldMapXML.AddAttribute "id", CStr(objWndField.GetID())
     End If
     FieldIter = FieldIter +1
     Set objWndField = objWindow.GetNextWindowField()
    Loop While FieldIter <= objWindow.CountFields()
   End If

  Set objWindow = objForm.GetNextWindow()
  WinIter = WinIter + 1
  Loop While WinIter <= objForm.CountWindows()

 End If
 Set objForm = GPApp.GetNextForm()
 FormIter = FormIter + 1

Loop While FormIter <= GPApp.CountForms()

objGPMapXML.SaveFile sGPMapXML
Set GPApp = Nothing
Set objForm = Nothing
Set objWindow  = Nothing
Set objWndField = Nothing
Set objGPMapXML = Nothing
Set objRoot = Nothing
Set objFormMapXML = Nothing
Set objWndMapXML = Nothing
Set objFldMapXML = Nothing

  • 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.