Question
· Nov 1, 2022

tablePane with OnCreateResultSet returns no results when referencing other namespace

Hi 

I have a  Zen Page with tablepane which has a datasource in a different namespace to that of the Zen Page. When the page is run, no data is returned and the tablepane is not populate,  even though the rerferenced table contains dat.

The tablePane code is as follows:

<tablePane id="DataExtractionCurrent"
	showZebra="true"
	cellSpacing="2px"
	OnCreateResultSet="DataExtractionCurrent">
</tablePane>

The OnCreateResultSet points to the following method:

Method DataExtractionCurrent(Output tSC As %Status, pInfo As %ZEN.Auxiliary.QueryInfo) As %ResultSet [ ZenMethod ]
{
  	new $namespace
    set $namespace = "DATAEXTRACTION"	
	
	#dim result as %ResultSet
	Set result=##class(%ResultSet).%New("%DynamicQuery:SQL")

  	Set tSC=result.Prepare("SELECT * from FairWarning_Table_Local.Logs")

  	w !, tSC	//  value of 1
  	
    quit result
}

Basically, the tablepane is not populated with data from the referenced table, which does contain data. However, it is picking up the column names and correctly displaying them in the table pane. Outputting tSC produces a value of 1.

I know the basic code does work, as changing it to reference a table in the same namespace as the current zen page returns resuls and populates the tablepane.

Any suggestions?

Cheers

Discussion (4)2
Log in or sign up to continue

Hi Andy,

The "problem" is that the Fetch is executed on the Namespace thats the zen page reside, and the data global doesn't exists or not mapped. A simple solution change the method to:

Method DataExtractionCurrent(Output tSC As %Status, pInfo As %ZEN.Auxiliary.QueryInfo) As %ResultSet [ ZenMethod ]
{
  New $Namespace
  set $Namespace = "DATAEXTRACTION"    
  
  #Dim result As %ScrollableResultSet = ##Class(%ScrollableResultSet).%New("%DynamicQuery:SQL")
  Set tSC=result.Prepare("SELECT * from FairWarning_Table_Local.Logs")
  Write !, tSC    //  value of 1
  Set tSC = result.Execute()
  Write !, tSC    //  value of 1
  Set tSC = result.%Save() // The class use temp globals that are mapped
  Write !, tSC    //  value of 1
  Return result
}

Bellow a test if your code:

The suggested code:

Regards