Question
· Aug 23, 2018

Set value to Property's DISPLAYLIST, VALUELIST

Hello Everyone,

I have a healthshare web application with production, I try to make a field in basic setting of business service, and I would like to set a string to DISPLAYLIST and VALUELIST of that Property (string maked by query to sql table). I code the same here but it's syntax incorrect in DISPLAYLIST = GetTypeDisplay(), VALUELIST = GetTypeValue(). Someone know a best way to solved my problem? Thanks so much!

Class Demo.RegDataService Extends Ens.BusinessService
{

Property xmlTagName As %String(DISPLAYLIST = ",EDocument", VALUELIST = ",Demo.EDocument");

Property PrdType As %String(DISPLAYLIST = GetTypeDisplay(), VALUELIST = GetTypeValue());

Parameter SETTINGS = "PrdType:Basic";

Parameter ADAPTER = "EnsLib.File.InboundAdapter";

ClassMethod GetTypeDisplay() As %String
{
    s result = ""
    &sql(declare CC1 cursor for
    SELECT TypeName INTO :typename FROM Demo_Data.PrdType)
    
    &sql(open CC1)
    &sql(fetch CC1)
    
    while(SQLCODE=0)
    {
        s result = result_","_typename
        &sql(fetch CC1)
    }
    &sql(close CC1)
    q result
}

ClassMethod GetTypeValue() As %String
{
    s result = ""
    &sql(declare CC2 cursor for
    SELECT TypeId INTO :typeid FROM Demo_Data.PrdType)
    
    &sql(open CC2)
    &sql(fetch CC2)
    
    while(SQLCODE=0)
    {
        s result = result_","_typeid
        &sql(fetch CC2)
    }
    &sql(close CC2)
    q result
}
Discussion (8)0
Log in or sign up to continue

I just want to make a select box in setting of business service in production. Example, if I set value the same below it will have result look like image

Property PrdType As %String(DISPLAYLIST = ",Type 1,Type 2,Type 3", VALUELIST = ",T1,T2,T3");

Parameter SETTINGS = "PrdType:Basic";

So I would like to use a method, classmethod or param replace string in DISPLAYLIST and VALUELIST

You can subclass Ens.ContextSearch to provide dynamic settings lists. Docs.

Here's a sample class  that adds ability to select XData in Ensemble setting.

/// Ensemble settings interface implementation
Class Package.EnsSearchUtils Extends %ZEN.Portal.ContextSearch
{

///Get class Xdata list.
ClassMethod GetXDatas(Output pCaption As %String, Output pTopResults, Output pResults, ByRef pParms As %String, pSearchKey As %String = "") As %Status
{
    Set tStatus = $$$OK
    Kill pResults, pTopResults
    Set pCaption = ""

    Set tClass = $get(pParms("class"))
    If tClass '= "" {
        Set tClassObj = ##class(%Dictionary.CompiledClass).%OpenId(tClass)

        For i=1:1:tClassObj.XDatas.Count() {
            Set pResults($i(pResults)) = tClassObj.XDatas.GetAt(i).Name
        }
    }
    Quit tStatus
}

}

For example to add a setting XSLTTransformation to BH that would allow me to choose on XData from my Package.XSLT class, I can specify SETTINGS parameter like  this:

Parameter SETTINGS = "XSLTTransformation:Basic:selector?context={Package.EnsSearchUtils/GetXDatas?class=Package.XSLT}";

First, I thanks so much for your help  Eduard Lebedyuk, I make a code the same below Classmethod and succeed get sql data to Setting.  But I have a new issue, DISPLAYLIST and VALUELIST (label and value of select box in setting) have the same value. Do you know some way to set different value to label and value of select box? example: DISPLAYLIST = TypeName and VALUELIST = TypeId.

Here my ClassMethod:

 ClassMethod GetPrdType(Output pCaption As %String, Output pTopResults, Output pResults, ByRef pParms As %String, pSearchKey As %String = "") As %Status
{
set tStatus = $$$OK
kill pResults, pTopResults
set pCaption = ""
set tStatement = ##class(%SQL.Statement).%New()
set strSQL="SELECT TypeId,TypeName FROM Demo_Data.PrdType"
     set tStatus = tStatement.%Prepare(strSQL)
if tStatus '= 1 Quit $$$ERROR($$$GeneralError, "No SQL Tables found")
     set rset = tStatement.%Execute()
while rset.%Next(.tStatus) {
set pResults($i(pResults)) = rset.%Get("TypeName")
}
quit tStatus
}