How could we store a list into a global variable?
Hello,
We would like to store a list into a global. The need is to get the full Web Service's Response Message, because of currently, our Operation sends the message to the Process, whith an empty list:
We have created a copyList which is a clone of the list which is being returned from the web service client:
set copyList = pResponse.RSPK21QUERYRESPONSE.%ConstructClone(1)
$$$LOGINFO("copyList: "_copyList)
$$$LOGINFO("copyList count: "_copyList.Count())
$$$LOGINFO("copyList.GetAt(1): "_copyList.GetAt(1))
$$$LOGINFO("copyList.PID8: "_copyList.GetAt(1).PID.PID8.content)
$$$LOGINFO("copyList serialize: "_copyList.Serialize())
We have checked that its content is being printed:
Now comes the challenge. We would need to store this copyList inside a global, to be able to use it inside the Process. However if we read globals' documentation it says:
" Each global node can contain a single string of up to 32K characters. "
We have tried the following to be able to store our copyList inside a global:
$$$LOGINFO("^globalList: "_^globalList)
//$$$LOGINFO("^globalList count: "_^globalList.Count())
$$$LOGINFO("^globalList.GetAt(1): "_^globalList.GetAt(1))
We are shocked because of it shows that ^globalList is a %Collection.ListObj
However if we uncomment the line:
//$$$LOGINFO("^globalList count: "_^globalList.Count())
The compiler outputs: " Missing subscript"
And if we uncomment the line:
It shows:
How could we store a list into a global? Is there a way to cast a list to string and be able to store it into a global?
We have read:
https://docs.intersystems.com/irislatest/csp/docbook/Doc.View.cls?KEY=GO...
https://docs.intersystems.com/irislatest/csp/documatic/%25CSP.Documatic....
https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...
https://cedocs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cl...
https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...
https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...
https://community.intersystems.com/post/what-best-way-serialize-objectli...
https://community.intersystems.com/post/globals-magic-swords-storing-dat...
https://cedocs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cl...
https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...
https://docs.intersystems.com/irislatest/csp/documatic/%25CSP.Documatic....
https://community.intersystems.com/post/serialize-and-deserialize-object...
https://community.intersystems.com/post/response-filled-bussiness-operat...
Besides we add the Operation's code:
{ Method operacion(pRequest As Mensajes.Request.GestionPacientes.operacionRequest, Output pResponse As Mensajes.Response.GestionPacientes.operacionResponse) As %Library.Status
{
SET RSPK21QUERYRESPONSE = ##class(%ListOfDataTypes).%New()
Set ..Adapter.WebServiceClientClass = "WSCLIENTE.GestionPacientes.ConsultaCandidatos"
Set MSH=pRequest.MSH,SFT=pRequest.SFT,QPD=pRequest.QPD,DSC=pRequest.DSC
Set tSC = ..Adapter.InvokeMethod("operacion",,.MSH,.SFT,.MSA,.ERR,.QAK,.QPD,pRequest.RCP,.RSPK21QUERYRESPONSE,.DSC) Quit:$$$ISERR(tSC) tSC
$$$LOGINFO("LLEGAN "_RSPK21QUERYRESPONSE.Count())
set pResponse = ##class(Mensajes.Response.GestionPacientes.operacionResponse).%New()
Set tSC = pRequest.NewResponse(.pResponse) Quit:$$$ISERR(tSC) tSC
Set pResponse.MSH = $get(MSH)
Set pResponse.SFT = $get(SFT)
Set pResponse.MSA = $get(MSA)
Set pResponse.ERR = $get(ERR)
Set pResponse.QAK = $get(QAK)
Set pResponse.QPD = $get(QPD)
Set pResponse.DSC = $get(DSC)
Set pResponse.RSPK21QUERYRESPONSE = $get(RSPK21QUERYRESPONSE)
$$$LOGINFO("LLEGAN "_pResponse.RSPK21QUERYRESPONSE.Count())
$$$LOGINFO("RSPK21QUERYRESPONSE.PID8: "_pResponse.RSPK21QUERYRESPONSE.GetAt(1).PID.PID8.content)
set copyList = ##class(%ListOfObjects).%New()
set copyList = pResponse.RSPK21QUERYRESPONSE.%ConstructClone(1)
$$$LOGINFO("copyList: "_copyList)
$$$LOGINFO("copyList count: "_copyList.Count())
$$$LOGINFO("copyList.GetAt(1): "_copyList.GetAt(1))
$$$LOGINFO("copyList.PID8: "_copyList.GetAt(1).PID.PID8.content)
$$$LOGINFO("copyList serialize: "_copyList.Serialize())
set ^globalList = copyList
$$$LOGINFO("^globalList: "_^globalList)
//$$$LOGINFO("^globalList count: "_^globalList.Count())
//$$$LOGINFO("^globalList.GetAt(1): "_^globalList.GetAt(1))
Quit $$$OK
}
{
<MapItems>
<MapItem MessageType="Mensajes.Request.GestionPacientes.operacionRequest">
<Method>operacion</Method>
</MapItem>
</MapItems>
} }