If you use versioning in your data dictionary, you need a way to determine the version number of a specific object in the currently selected database. DataEngine.GetObjectVersion is the means. This script is called after the data dictionary has been loaded to determine which objects, if any, should be hidden because of versioning issues.

A reference to the Stonefield Query Application object, the name of the object, and the object type: "field," "table," or "relation."

Return Value
The version number of the object as a string or a blank string if there is no version number.

Suppose the first two characters of the table name represent the module the table belongs to (for example, ARCUS is the customers table in the AR, or Accounts Receivable, module). Also suppose a table named CSAPP contains the version number of each module. The following code returns the version number from the current database for the module the specified table or field belongs to. Note that rather than opening CSAPP each time, this code assumes it was opened in the DataEngine.GetCustomMetaData script for performance reasons.

Visual FoxPro


lparameters toApplication as SQApplication
loDatabase = SQApplication.DataEngine.Databases.GetMainDatabase()
loDatabase.ExecuteSQLStatement('select MODULE, VERSION from CSAPP', , 'CSAPP')


lparameters toApplication as SQApplication, tcObjectName, tcObjectType
local lcModule, lcVersion
lcModule = left(tcObjectName, 2)
select CSAPP
locate for MODULE = lcModule
lcVersion = VERSION
return lcVersion



function Main(Application)
dim Database, XMLDOM
set Database = Application.DataEngine.Databases.GetMainDatabase()
VersionXML = Database.ExecuteSQLStatement("select MODULE, VERSION from CSAPP")
set XMLDOM = createobject("MSXML.DOMDocument")
XMLDOM.ASync = False
Application.AddProperty "VersionXML", XMLDOM
Main = True
end function


function Main(Application, ObjectName, ObjectType)
dim Node
Module = left(ObjectName, 2)
NodePath = "/DataSet/_resultset[@module='" + Module + "']"
Node = Application.VersionXML.selectSingleNode(NodePath)
Main = Node.getAttribute("version")
end function



function Main(Application) {
var Database, VersionXML, XMLDOM ;
Database = Application.DataEngine.Databases.GetMainDatabase() ;
VersionXML = Database.ExecuteSQLStatement('select MODULE, VERSION from CSAPP') ;
XMLDOM = new ActiveXObject('MSXML.DOMDocument') ;
XMLDOM.ASync = false ;
XMLDOM.LoadXML(VersionXML) ;
Application.AddProperty('VersionXML', XMLDOM) ;
return true ;


function Main(Application, ObjectName, ObjectType) {
var Module, NodePath, Node, Version ;
Module = left(ObjectName, 2) ;
NodePath = '/DataSet/_resultset[@module="' + Module + '"]'
Node = Application.VersionXML.selectSingleNode(NodePath) ;
Version = Node.getAttribute("version") ;
return Version


Please note that the method in this script must be named DataEngine_GetObjectVersion.

public static string DataEngine_GetObjectVersion(SFQApplication sfqApplication, 
  string objectName, string objectType)
  string version = String.Empty;
  XmlDocument doc = null;
    doc = (XmlDocument)sfqApplication.GetProperty("VersionXML");
  catch(Exception e)
  if(doc == null)
    Database database = sfqApplication.DataEngine.Databases.GetMainDatabase();
    string selectStmt = "select MODULE, VERSION from CSAPP";
    string resultSet = database.ExecuteSQLStatement(selectStmt);
    doc = new XmlDocument();
    sfqApplication.AddProperty("VersionXML", doc);
  string module = objectName.Substring(0, 2);
  string nodePath = "/DataSet/_resultset[@module=\"" + 
    module + "\"]";
  XmlNode node = doc.SelectSingleNode(nodePath);
  if (node != null)
    version = node.Attributes["version"].Value;
  return version;


Please note that the method in this script must be named DataEngine_GetObjectVersion.

public shared function DataEngine_GetObjectVersion(sfqApplication as SFQApplication, _
  objectName as string, objectType as string) as string
  Dim version As String = String.Empty
  Dim doc As XmlDocument = Nothing
    doc = sfqApplication.GetProperty("VersionXML")
  Catch e As Exception
  End Try
  If (doc Is Nothing) Then
    Dim database As Database = sfqApplication.DataEngine.Databases.GetMainDatabase()
    Dim selectStmt As String = "select MODULE, VERSION from CSAPP"
    Dim resultSet As String = database.ExecuteSQLStatement(selectStmt)
    doc = New XmlDocument()
    sfqApplication.AddProperty("VersionXML", doc)
  End If
  Dim moduleName as string = objectName.Substring(0, 2)
  Dim nodePath As String = "/DataSet/_resultset[@module=""" +
    moduleName + """]"
  Dim node As XmlNode = doc.SelectSingleNode(nodePath)
  If (Not node Is Nothing) Then
      version = node.Attributes.GetNamedItem("version").Value
  End If
  Return version
End Function

See also

DataEngine.GetCustomMetaData | Scripts