David Crawford · Jun 18, 2018 go to post

Right that's a big one. But unless it's severely delayed, the last log in there for me was a couple hours ago and I just now made the error again.

David Crawford · Jun 18, 2018 go to post

Do you mean like %SYS or whatever else is available in the application log page? If so unfortunately there's only %sys and ensemble, which both don't have anything new in them.

David Crawford · Jun 18, 2018 go to post

Hey thanks for looking into the source! This should hopefully suffice for what we need.

David Crawford · Jun 11, 2018 go to post

Unfortunately I don't know how to go about altering that value after or before it's been generated. You may have to experiment with including custom functions in your tags that output page numbers, or try to get the value from the special tag into one of your custom tag functions. Whatever you do, there doesn't seem to be a native way and you'll have to do something custom.

David Crawford · Jun 8, 2018 go to post

I'll try to answer just the conversion question. It looks like someone has asked about roman numerals before here:

https://community.intersystems.com/post/roman-number-converter

However the conclusion was that the referenced article in that question here:

http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.FrameSet.cls?KEY=GVRF_basicfeatures

Doesn't support roman numeral conversion. Now there's a billion ways to do this yourself, and I was inspired by the unary method in one of the answers here, instead of complex loops:

https://stackoverflow.com/questions/12967896/converting-integers-to-roman-numerals-java

So I made something similar for ObjectScript, and it gets the job done in a very simple way. Note that it doesn't use a full Subtractive method for conversion, for that you'll need more cases. The replaces could be structured differently too but I wanted it to be as understandable as possible. Call it in your report however you like.

ClassMethod RomanNumeralConversion(pNum) As %Status {
   set roman = ""
   for x=1:1:pNum {
    set roman = roman_"I"
   }
 
   set roman = $REPLACE(roman,"IIIII", "V")
   set roman = $REPLACE(roman,"IIII","IV")
   set roman = $REPLACE(roman,"VV","X")
   set roman = $REPLACE(roman,"VIV", "IX")
   set roman = $REPLACE(roman,"XXXXX", "L")
   set roman = $REPLACE(roman,"LL", "C")
   set roman = $REPLACE(roman,"LXL", "XC")
   set roman = $REPLACE(roman,"CCCCC", "D")
   set roman = $REPLACE(roman,"CCCC", "CD")
   set roman = $REPLACE(roman,"DD", "M")
   set roman = $REPLACE(roman,"DCD", "CM")
   return roman
}
David Crawford · Feb 20, 2018 go to post

What you've shown me inspired me to try something else...I can't draw from %request.Content.Data directly because it's always undefined, so I've had to use Read() all of the time whenever I need Data values from POST messages.

This seems to be working for any size so far, and I think I can come up with something more efficient later, but at least it's working!

set stream = ##class(%Stream.GlobalCharacter).%New()
While (%request.Content.AtEnd = 0) {
     Set len = $$$MaxStringLength
     do stream.Write(%request.Content.Read(.len))

}

//etc..


Set outputStream = ##class(%Stream.GlobalCharacter).%Open(oid)
While (outputStream .AtEnd = 0) {
     Set len = $$$MaxStringLength
     Write outputStream .Read(.len)
 }
David Crawford · Feb 20, 2018 go to post

I'm just trying to send a large chunk of characters, have it stored as a stream, and then returned to the client. Thank you for your advice though, I'll figure something out hopefully, at least I know what can be done.

David Crawford · Feb 20, 2018 go to post

What if I need to read something that is beyond the max string length? Do I have to break it up into segments?

David Crawford · Feb 20, 2018 go to post

Aha you're absolutely right. It was so simple, thank you! SizeGet() was accurate and I overrode the Read() default.

David Crawford · Feb 15, 2018 go to post

Fantastic! This is perfect, thank you so much!

From your example, at a minimum I had to add two parameters to my ajax:

contentType: "application/json",
dataType: "json",

And then to retrieve them, the REST service simply needs this to send back to the client whatever was in the message:

set jsonstring = $ZCONVERT(%request.Content.Read(),"I","UTF8")
set data = {}.%FromJSON(jsonstring)
write data.%ToJSON()

Thanks again!

David

David Crawford · Feb 15, 2018 go to post

The message gets sent and a reply comes through successfully, but the body information still isn't seen by the rest service.

David Crawford · Feb 15, 2018 go to post

Yes, this is the whole call, with the intention of receiving whatever I sent back to me:

$.ajax({
                headers: { "Authorization": "Basic " + btoa("username:password") },
                url:"serverurl/returnresponse",
                type: "POST",
                data: {
                    "payload": "some data"
                },
                success: function (response) {
                    console.log(response);
                }

});

 

Then the route:

<Route Url="/returnresponse" Method="POST" Call="ReturnResponse" Cors="false"/>
 

The method:

ClassMethod ReturnResponse() as %Status {
    try {
        set obj = %request.Data //...Contents...etc.
        write obj   
    }
    catch ex {
        write ex.Name
    }
    return $$$OK
}

David Crawford · Jan 16, 2018 go to post

Hello,

From what you've provided, this looks like a javascript error simply indicating that the function it's looking for doesn't exist. How are you calling cspHttpServerMethod? In the section Calling Server-side Methods Using #server on this documentation chapter, the proper javascript syntax is given to call server-side methods.

For example from the doc,

function test(value)
{
   // invoke server-side method Test
   #server(MyPackage.Test(value))#;
}