One additional modification to @Stuart.Strickland8116's most amazing attempt:

N(i)
 j=1:1:$l(i) c=$e(i,j),o=$g(o)_$s(",.!?"[c:c,c?1a:$e(" ",j>1)_$ZCVT(c,"U")_$p("lfa77harlie7elta7cho7oxtrot777ndia7777ike7ovember7scar777omeo777niform7777ankee",7,$a(c)#32),1:"")
 o

180 192 characters, assuming Unix line endings and a ridiculously limited use case that still solves the problem devil

EDIT: Added 12 characters to add fix for capitalized output ...

Hi @Eduard Lebedyuk,

I recently implemented this mechanism for handling ad-hoc message selection queries to the Google Health HL7v2 Store, and wanted to share a modification needed to satisfy the customer.

Their concern was that the service name was hard-coded in the dispatch class, and that they would have to touch the code if they used the class with a differently named service. To resolve that, I added a TargetConfigName property to the otherwise empty proxy service along with a SETTINGS parameter to reveal it through the configuration panel and allow the user to configure it.

I then modified the methods in the dispatch class to expect the service name in the URL "launch" argument and interrogate the production for the specified service's TargetConfigName value.

As always, thank you for the informative articles and answers!

Do you need the eventual user to be prompted for a password when opening the PDF? If so, you'll need to push it through an external application/utility (under IRIS/Cache control) that supports command-line password protection for the output file.

If you just need to encrypt the file for delivery but don't need the user to be prompted for a password when opening the document, there are a number of encryption options in the %SYSTEM.Encryption class.

I'm seeing some interesting behavior in the Production view, and I think it has something to do with changes made to the way active items are colored when not actually running. The Proxy Service's status icon always displays pale green when enabled, while other items that are enabled display a dark green icon. This is behavior I first noticed in HealthConnect/IRIS4Health with 2020.1 in relation to scheduled hosts. Although they were enabled, they would only display in the dark green color when the schedule started them and would revert to pale green when the schedule stopped them.

I'm just curious to know if there's a way to force the proxy service to display a "normal" dark green icon, even though it's not actually doing anything.

Hi @Eduard Lebedyuk ,

I'm working on what I expected to be a fairly simple web service that would accept a JSON payload as the body. I started with your code and instructions here, but I can't seem to get past this error:

While the class appears to be dispatched properly, It appears that the %request object has no Data property, and I'm not understanding why.

I searched for other examples of the %request object in the InterSystems-supplied classes and found no reference to the Data member, so am unsure how to proceed. Thanks in advance for your help!

You appear to be attempting to call the method from the debugger. Type Q to return to the normal Cache/IRIS prompt and try again ... let me know what happens.

Being in the debugger shouldn't be a problem unless you have the Secure Debug Shell enabled. There are a lot of things you can't do from the debugger when that's enabled, and one of them is using the SET command.

I tested the method on my own system before posting it, so I'm not sure why you're getting the error.

Did you compile the class after saving it?

Are you certain the name of the production is spelled correctly?

Are you in the proper namespace?

EDIT: I also added a tiny bit of error checking to the original method ... note the Return statement after the line Set tPrd...

Here's a method that might get you close to what you want:

ClassMethod GetHostsByAdapter(pProduction As %String, pAdapterName As %String) As %List
{
        Set tPrd = ##class(Ens.Config.Production).%OpenId(pProduction)
        Return:'$ISOBJECT(tPrd) "Production does not exist!"
        Set tItems = tPrd.Items
        Set tItemCnt = tItems.Count()
        Set tHostList = ""
        Set tCnt = 1
        For i=1:1:tItemCnt
        {
            Set tItem = tItems.GetAt(i)
            If $CLASSMETHOD(tItem.ClassName,"%GetParameter","ADAPTER") = pAdapterName
            {
                Set $LIST(tHostList,tCnt) = tItem.Name
                Set tCnt = tCnt + 1
            }
        }
        Return tHostList
}

Call it with:

Set hosts=##class(<classname>).GetHostsByAdapter("<production name>","EnsLib.HTTP.InboundAdapter")

The variable hosts will contain the list (in $LIST form) of business hosts that have the adapter specified as the 2nd argument.

I'm posting this as a potential solution. I imagine there are smarter ways of doing this. Hoping someone will jump in and show me the way 😁

I've written a classmethod that accepts 3 arguments: the lower and upper limits of the IDs to select, along with the number of records you'll want to select:

Class Sample.Rand
{
ClassMethod RandList(pMin As %Integer, pMax As %Integer, pLen As %Integer = 10) As %String [ SqlName = List, SqlProc ]
{
        Set tList = ""
        Set tCnt = 1
        For i=1:1:pMax
        {
            Set tNum = $R(pMax + 1)
            If tNum >= pMin
            {
                Set $LIST(tList,tCnt) = tNum
                Set tCnt = tCnt + 1
            }
            Quit:(tCnt > pLen)
        }
    Return tList
}
}

The method can be called as a custom SQL function in a subquery:

SELECT * FROM MyTable WHERE %Id %INLIST (SELECT Sample.List(MIN(%Id),MAX(%Id),10) FROM MyTable)

The query above will select up to 10 rows randomly from table MyTable.

Caveats: This could take a long time to run if your range from minimum to maximum %Id is large. And it's not guaranteed to return the number of rows specified as the 3rd argument (there may be deleted records, or insufficient random values generated before the upper limit for %Ids is reached). Finally, it assumes that %Id is numeric.

EDIT: And as pointed out by @Julius Kavay, @Robert Cemper has a better idea (he usually does 😉)