Written by

Senior Developer at Greater Manchester Mental Health Services
Question Andy Stobirski · 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:

<tablePaneid="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$namespaceset$namespace = "DATAEXTRACTION"#dim result as%ResultSetSet result=##class(%ResultSet).%New("%DynamicQuery:SQL")

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

  	w !, tSC	//  value of 1quit 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

Comments

Cristiano Silva · Nov 1, 2022

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$Namespaceset$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 1Set tSC = result.Execute()
  Write !, tSC    //  value of 1Set tSC = result.%Save() // The class use temp globals that are mappedWrite !, tSC    //  value of 1Return result
}

Bellow a test if your code:

The suggested code:

Regards

0
Andy Stobirski  Nov 4, 2022 to Cristiano Silva

Hi Cristiano - that worked perfectly. Thanks for replying.

0
Andy Stobirski  Nov 4, 2022 to Ian Pears

That was very helpful. Thanks for posting.

0