If you're trying to access data across several namespaces of the same instance you don't need xDBC. Use either mappings or queries with local cache to move data.
- Log in to post comments
If you're trying to access data across several namespaces of the same instance you don't need xDBC. Use either mappings or queries with local cache to move data.
It was an error in the example - Data does not exist.
I now fixed my example.
Well, in this case you definitely don't need to read from stream at all. You can save the stream in the database (or file using %Stream.FileCharacter)) and send it to the client later:
set stream = ##class(%Stream.GlobalCharacter).%New() set sc = stream.CopyFromAndSave(%request.Content) set oid = stream.%Oid() kill (oid) set stream = ##class(%Stream.GlobalCharacter).%Open(oid) do stream.OutputToDevice()
Streams can be class properties too.
What do you need to do? Many actions can be either performed with streams or there's a workaround.
But ultimately yes, if the stream is beyond max string length (3641144 symbols) you'll need to process it chunk by chunk.
Can you write
Sourcedata.Date
into a global? What's its value?
How did you determine that problem happens directly at allocation (setting the property)?
Try:
%request.Content.Data.Read($$$MaxStringLength)
If you have json you can cast it into object without reading the stream in user code:
Set obj = {}.%FromJSON(%request.Content.Data)Same for XML (you can get it from Stream or even from url).
catch-scope is not seems to be reached
Have you enabled logging?
Error occurs on saving incorrect data and not on setting the data. Saving also does not throw an exception, only returns an error status.
Also you need to quit something:
#dim sc As %Status = $$$OK
try
{
set myClass= ##class(SomeClass).%New()
myClass.Date = Sourcedata.Date //Sourcedata send us wrong format to that datefield.
set sc = myClass.%Save() // Error occurs on save.
} catch ex {
set sc = ex.AsStatus()
set errMsg = "Error in this method " _ $System.Status.GetOneStatusText(sc)
$$$LOGERROR(errMsg)
}
quit scOn a side note, you're using 3 different naming conventions for variables in your snippet:
It would probably be better to decide on one notation.
I'd recommend developing a REST API and Web application (you can pack it via Cordova, etc.)?
Even better, you can write a responsive web application and not bother with packers altogether. Unless you need things like camera/gps... a responsive web site is easier to develop and support.
Subclass EnsLib.EMail.AlertOperation? It's hardcoded there.
Have you modified Import method in your class to show errors?
if $$$ISOK(tStatus) { set tCounter = tCounter + 1 } else { w $System.Status.GetErrorText(tStatus) return}Most likely you're getting an error and import stops.
All datatypes go through the transformation.
The collation is determined in this order:
Almost the same:
set json = "{""prop"":1}"
set obj = {}.$fromJSON(json)
write obj.prop
If you're on 2016.2+:
set json = "{""prop"":1}"
set obj = {}.%FromJSON(json)
write obj.prop
The general approach is:
Sample code (SAMPLES namespace):
/// This is the Desktop Demonstration page for the Zen demonstration application.
Class ZENDemo.AutoDemo Extends %ZEN.Component.page
{
/// Class name of application this page belongs to.
Parameter APPLICATION = "ZENDemo.Application";
/// This XML block defines the contents of this page.
XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ]
{
<page xmlns="http://www.intersystems.com/zen" title="Zen Desktop Demo">
<tablePane sql="SELECT ID,Name FROM Sample.Person WHERE Name %STARTSWITH ? ORDER BY Name">
<column colName="ID" hidden="0"/>
<column colName="Name"/>
<parameter value="Z"/>
</tablePane>
</page>
}
/// Toggles visibility of the ID column.
/// w $System.Status.GetErrorText(##class(ZENDemo.AutoDemo).Modify())
ClassMethod Modify() As %Status
{
#Dim pSC As %Status = $$$OK
#Dim tPage As %ZEN.Component.page
#Dim tHidden As %Boolean
Set tSC = ..GetPageObject(, .tPage)
Quit:$$$ISERR(tSC) tSC
Set tHidden = tPage.children.GetAt(1).columns.GetAt(1).hidden
Write "Old ID column hidden value: ", tHidden, !
Set tPage.children.GetAt(1).columns.GetAt(1).hidden = 'tHidden
Write "New ID column hidden value: ", 'tHidden, !
Set tNewStream = ##class(%Stream.TmpCharacter).%New()
Set tSC = ##class(%ZEN.Utils).%ObjectToXML(tNewStream, tPage)
Write "New XData: ", 'tHidden, !
Do tNewStream.Rewind()
Do tNewStream.OutputToDevice()
Do tNewStream.Rewind()
Set tSC = ..SavePage(,tNewStream)
Do $system.OBJ.Compile($classname())
Quit tSC
}
ClassMethod GetPageObject(pClassName = {$classname()}, Output pPage As %ZEN.Component.page) As %Status
{
Set tReader = ##class(%XML.Reader).%New()
Set tSC = tReader.OpenStream(##class(%Dictionary.CompiledXData).%OpenId(pClassName _ "||" _ "Contents").Data)
If $$$ISERR(tSC) Quit tSC
Do tReader.Correlate("page","%ZEN.Component.page")
#; there should only be one page defined
Do tReader.Next(.pPage,.tSC)
Quit:$$$ISERR(tSC) tSC
Quit:'$IsObject(pPage) $$$ERROR($$$GeneralError,"No <page> element defined in Contents block.")
Quit tSC
}
ClassMethod SavePage(pClassName = {$classname()}, pStream) As %Status
{
Set tCDef = ##class(%Dictionary.ClassDefinition).%OpenId(pClassName)
If '$IsObject(tCDef) {
Set tSC = $$$ERROR($$$GeneralError,"Unable to open class definition: " _ tClass)
}
#; find XDATA Contents block
Set tIndex = tCDef.XDatas.FindObjectId(pClassName _ "||" _ "Contents")
If (tIndex '= "") {
#; get XDATA as stream
Set tStream = tCDef.XDatas.GetAt(tIndex).Data
Do tStream.CopyFrom(pStream)
}
Else {
#; create a new XData block !!!
}
Set tSC = tCDef.%Save()
Quit tSC
}
}Calling:
Write $System.Status.GetErrorText(##class(ZENDemo.AutoDemo).Modify())
Toggles visibility of the ID column.
Check this article.
Okay.
Another idea: you can define your session event class, and set it as a session event class for your web application. That way you can track:
If I do a direct link without using the router it works fine
How fo you test directly? If you're doing it from a terminal, then that terminal process works as your OS user. Ensemble works under another OS user. Check that this user has access to file.
In what context are you encountering IDKEY?
While Primary Key, ID and IDKEY refer to the same concept, there are some nuances:
Angular pages are often templates filled with data (via REST) and so it' possible to use that. In the root broker of the application add request tracking (who accessed what and when).
OnPreDispatch method works for that purpose.
/// This method Gets called prior to dispatch of the request. Put any common code here
/// that you want to be executed for EVERY request. If pContinue is set to 0, the
/// request will NOT be dispatched according to the UrlMap. If this case it's the
/// responsibility of the user to return a response.
ClassMethod OnPreDispatch(pUrl As %String, pMethod As %String, ByRef pContinue As %Boolean) As %Status
{
Quit $$$OK
}
Just try to create/open random new file in a directory.
Here's how you can do it
Documentation:
How do you test?
Terminal runs under your own OS user.
Thank you. I should have searched better.
My assumption is that you are suggesting to define a class and create a list of objects which then get passed back to the BPL
Yes, something like that. Or you can pass only id's of saved objects back. That makes ensemble messages lighter.
Check this article on delegated authentication.
I am setting the software defined username in the Properties("Comment") array and wanting to reference it in the Rest Service Dispatch class.
Do you see delegated user getting created?
Properties("Comment") should be available as this user Comment property.
is there a way to return more specific messaging regarding the failure to the calling web application?
iirc both ZAUTHENTICATE main entry point and GetCredentials entry point return %Status so you can pass the error there.
Snapshot is a very technical abstraction.
If possible, it's better to convert it to business object(s) and pass that.
What is your question?
Declarative programming is somewhat related.