#ObjectScript

14 Followers · 1.6K Posts

InterSystems ObjectScript is a scripting language to operate with data using any data model of InterSystems Data Platform (Objects, Relational, Key-Value, Document, Globals) and to develop business logic for serverside applications on InterSystems Data Platform.

Documentation.

Article Evgeny Shvarov · Mar 13, 2020 2m read

Hi developers!

Suppose you have a Github repository with ObjectScript classes but without a Docker environment.

Recently I published a repository with a set of files that form a universal Docker and VSCode environment to let you either import and run your repository in InterSystems IRIS Community Edition on Docker or turn your repository into Docker and VSCode environment for InterSystems IRIS Community Edition.

So in one sentence:

Unpack these files in your folder and you have the Docker and VSCode environment for your InterSystems IRIS ObjectScript application!

See the details below.

0
1 785
Question Stephen Wilson · Mar 11, 2020

There does not seem to be any separation between the error code and error text in a %Status object. For custom errors, I simply want to display the message and not Error #5001: Some error text.

ClassMethodIsNonNullCustomerID(pCustomerIDAs%String) As%Status  {
Quit:(pCustomerID="")$$$ERROR($$$GeneralError,"CustomerID is not valid")
Quit$$$OK
}

The various methods described here to retrieve the error text always show

Error  #5001: CustomerID not valid

Without manipulating the string above, can you get the "CustomerID not valid" message cleanly from the %Status object and in as few

5
0 738
Question Yone Moreno · Mar 5, 2020

We would like to be able to store accented characters into an API.

Currently our Rest Operation is the following:

Class Operaciones.REST.NotificacionesPUSH.CrearNotificacion Extends EnsLib.REST.Operation
{Parameter INVOCATION = "Queue";Method CrearNotificacion(pRequest As Mensajes.Request.NotificacionesPUSH.CrearNotificacion, pResponse As Mensajes.Response.NotificacionesPUSH.CrearNotificacion) As %Library.Status
{
Set body = {
     "app_id"(pRequest.idApp),
     "headings"{"en":(pRequest.notificacion.titulo),"es":(pRequest.notificacion.titulo)},
     "subtitle"{"en":(pRequest.notifi




10
0 2747
Question Yone Moreno · Mar 5, 2020

We need to get service's both source and target names. We have checked that we could obtain them in the service:

set ^sourceName = ..#SERVICENAME

However we would like to get it directly from the BPL. We have tried:

Set SourceConfigName = ..%PrimaryRequestHeader.SourceConfigName
  $$$LOGINFO("SourceConfigName "_SourceConfigName)

And the compiler outputs:

ERROR: Procesos.HistoriaClinica.ConsultaDatosHCEPaciente.Thread1.cls(S161+247) : MPP5376 : Method or Property '%PrimaryRequestHeader' does not exist in this class.

How could we access to %PrimaryRequestHeader property inside Ens.

2
0 881
Question Kevin McGinn · Feb 28, 2020

I am new to Intersystems cache COS scripts (cache is a client system). ThoughCOS scripts basically appear to be straight forward, I am having issues with the logon credentials. From what I have found in the documentation, the first 2 lines of the script contain the U/P. When running the script, the username is picked up correctly but the password is not. Granted, having U/P in a script is not ideal but will suffice as a matter of learning if I can figure out the formatting/syntax required. Any help on this would be appreciated.

Kevin McGinn

3
0 375
Question Ilmija Asani · Feb 18, 2020

Hello,

we are trying to figure out if there's a way to create a SOAP Envelope by using SOAP classes.

Right now we use a string to define the envelope element.

The string looks like :

<soap:Envelope xmlns:soap='http://www.w3.org/2003/05/soap-envelope' xmlns='urn:oasis:names:tc:SAML:2.0:assertion'>
    <soap:Header>
        <add:Action xmlns:add='http://www.w3.org/2005/08/addressing'>urn:rve:AuthenticateAndGetAsserti…;
        <add:MessageID xmlns:add='http://www.w3.org/2005/08/addressing'>urn:uuid:_MessageID_</add:Message…;
        <add:To xmlns:add='http://www.w3.org/2005/
2
0 885
Announcement alex kosinets · Feb 8, 2020

Ladies and gentlemen, good news for our town.

It finally happened  - M was put in the cell.

And feels great there. Maybe it not a prison but an Excel cell.

Being there, he leads the whole M-gang. As well as conditional formatting in EXCEL.

Close integration of excel with the database provides a new convenient design tool.

Interactive reports, input forms, diagrams are generated only by m-commands in cells, without classical programming.

More detailed on https://github.com/mx-alex/MX

We will monitor the development of the situation and answer your questions.

best wishes

Alex

19
1 1670
Article alex kosinets · Feb 29, 2020 4m read

There is a special Query for reporting, it takes one cell of Excel. Example :

?$$omQuery 113^oPeat | Country   Country:Province   Date   Product:Date   Date:Product:-zr   | tn EURO | zrzr| | if Date'<%XD81,Date'>%XD82 |  set zrzr=zr,EURO=summa

The omQuery sets the structure and content of the required documents as well as filters and data processing procedures.

In one request, up to 9 reports are created, with subtotals by group. (5 here , 3 with:subtotals )

All issued documents retain the interactivity property - any manipulations with cells are displayed in excel and in virtual m-excel s

0
0 266
Article Robbie Luman · Feb 28, 2020 3m read

Our company is in the process of converting our software for use in Intersystems IRIS and one of the major sections of the software makes use of a custom statically-linked C library using the $ZF("function-name") functionality. During this, I found out that the process for setting up the C library to be used within the database platform has changed significantly between Cache and IRIS.

If you have used or still use the C Callout Gateway with Cache, then you will know that in order for Cache to be made aware of any functions provided in a custom C library to be used with $ZF("function-name"),

0
0 408
Question Akshat Vora · Jan 23, 2020
   try{
        ....
        ....
        ....

        Set tSC = method_invocation()

        If $$$ISERR(tSC) {
            Quit tSC
        }

        ....
        ....
        ....

}

On compiling the above, I get an error saying "QUIT argument not allowed : 'tSC' ".

  • When I replace Quit tSC with Return tSC, it compiles
  • On replacing Quit tSC with Quit $$$OK, I get the error: QUIT argument not allowed : '1'
  • On replacing Quit tSC with Quit, it compiles
  • A 'Quit tSC' statement outside of the try-catch block does not cause a compile-time error.

The reason this happens is

9
0 1204
Question Akshat Vora · Feb 22, 2020

I need to convert an array with an unknown number of indices to a JSON string for transmission (which is why it isn't possible to iterate through it using $ORDER). Does ObjectScript provide functionality to convert an array to a JSON string?

Edit 1: As Joel mentioned, the array is subscripted and has an arbitrary structure like:

a(1)="a"
a(3,4)="b"
a(3,6)="c"
a(5,6,7)="d"

which needs to be converted to

{"1":"a", "3":{"4":"b","6":"c"}, "5":{"6":{"7":"d"}}}

I had considered using a combination of $Query (to traverse the array) and $Order (to retrieve property names) but was wondering

6
0 1892
Question Yone Moreno · Feb 6, 2020

Hello,

We have the following code:

Method incorporarDocumento(request As EsquemasDatos.incorporarDocumentoRequest(REQUIRED=1)) As EsquemasDatos.documentoIncorporado(XMLNAME="return") [ Final, ProcedureBlock = 1, SoapBindingStyle = document, SoapBodyUse = literal, WebMethod ]
{
set ..MTOMRequired = 1set ..SecurityOut.actor = "http://www.gobiernodecanarias.org/Platino/Authentication/1.0"
    set ..SecurityOut.mustUnderstand = "1"
    set ..SecurityNamespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-util…"
        
//BINARY SECURITY TOKEN
    set x509alias =

1
1 451
Question Mikael Toivonen · Feb 23, 2020

In a HTTP operation, which extends Ens.BusinessOperation, EnsLib.REST.Operation, one can read the component's AlertGroups property by simply referring to it with "..":

set AlertGroup =  ..AlertGroups//Do something with AlertGroup

 

"AlertGroups" is a property of Ens.Host. The above however  does not work in a business process which Extends Ens.BusinessProcessBPL which extends Ens.BusinessProcess which extends Ens.Host. Can this property be read from inside the business process and what would the syntax be? 

As the end result I would like to include the component's AlertGroups prope

2
0 315
Question Anthony Rosania · Feb 23, 2020

First,

Forgive me if this is a rather low-level question - I am a physician informaticist who is learning cache/mumps for the first time. I am sure this probably relates to some setting but I can't find a similar issue anywhere.

When I create a list, and then try and return that list - I get a bunch of symbols back along with my results, or sometimes I just get symbols. 

I pasted a screenshot below.  Thank is advance for the help!

Anthony

6
0 327
Article Evgeny Shvarov · Feb 21, 2020 1m read

Hi Developers!

Another way to start using InterSystems ObjectScript Package Manager is to use prebuilt container images of InterSystems IRIS Community Edition and InterSystems IRIS for Health Community Edition.

We deploy this IRIS images on DockerHub and you can run it with the following command:

docker run --rm -p 52773:52773 --init --name my-iris -d intersystemsdc/iris-community:2019.4.0.383.0-zpm

Launch a terminal with:

docker exec -it my-iris iris session IRIS

And install zpm-module as:

USER>zpm 

zpm: USER>install objectscript-math

[objectscript-math] Reload START

[objectscript-math] Reload SUCCESS

[objectscript-math] Module object refreshed.

[objectscript-math] Validate START

[objectscript-math] Validate SUCCESS

[objectscript-math] Compile START

[objectscript-math] Compile SUCCESS

[objectscript-math] Activate START

[objectscript-math] Configure START

[objectscript-math] Configure SUCCESS

[objectscript-math] Activate SUCCESS

zpm: USER>

And use same commands for InterSystems IRIS for Health using the tag: intersystemsdc/irishealth-community:2019.4.0.383.0-zpm

The images are being published on IRIS Community Edition and IRIS Community Edition for Health repositories of Docker Hub.

We will update tags with every new release of IRIS and ZPM.

Happy coding!

0
1 429
Question Yone Moreno · Feb 18, 2020

Hello,

We would like to get the XML which is being given by the requested system, directly to our Service output.

We have tried to just output directly the Message Response as follows:

Method findCandidatesXML(mensEntrada As %XML.GlobalCharacterStream(CONTENT="MIXED")) As Mensajes.Response.GestionPacientes.operacionResponse(XMLNAME="mensSalida") [ Final, ProcedureBlock = 1, SoapAction = "http://SCS.Servicios/GestionPacientes/findCandidatesXML", SoapBindingStyle = document, SoapBodyUse = literal, WebMethod ]
{
    set ^tipoMensaje="XML"
    $$$LOGINFO("El mensaje es de tipo: "_^tipoMensaj



2
0 940
Question Yone Moreno · Feb 13, 2020

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 = ##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: "_



2
0 312
Question Stephen Wilson · Feb 4, 2020

I am looking to run some analysis on existing software to quickly identify global variable references. Ideally you would feed in a "starting routine" and after going through all referenced routines you would end up with a finite set of global variables. So the primary purpose is to take say 10,000 lines of code and map out the referenced global structures without relying on a programmers eye. I found the post on Object Script equivalent to Studio "Find in Files" interesting but the downside is that output is too verbose and would require parsing to extract the global structures. How would you override writing to the terminal so that you could parse the data?

4
0 1154
Discussion Adel Elsayed · Feb 8, 2020

I'm looking into finding ways to  fetch data from cache efficiently and work with it with python - specially pandas.

i tried the following but i'm wondering if this is the most efficient way?

to run the stored procedure as %ResultSet inside cache in a classmethod and serialize the data to JSON

and then call that class method from python

Class User.RegObj Extends %RegisteredObject{ClassMethod runAlpha() As %Library.DynamicAbstractObject{set QHi=##class(%DynamicAbstractObject).%FromJSON("{}")set rs=##class(%ResultSet).%New("User.Person:alpha")set pr=rs.Execute("","")set idx=0w
5
0 723
Question Yone Moreno · Feb 7, 2020

Hello,

We would like to submit a JSON using Ensemble. Here we have the JSON structure:

{
    "app_id": "e47322de-64c8-43c5-a1b7-42aa6409eb48",
    "headings": {"en":"Cita Atencion Primaria","es":"Cita Atencion Primaria"},
    "subtitle": {"en":"C.P. ISORA","es":"C.P. ISORA"},
    "contents": {"en": "Next appointment", "es": "Siguiente cita"},
    "data":{
                "centro": "C.P. ISORA",
                
                "fecha": "yyyy/mm/dd",
                
                "hora": "hh:mm",

                "profesional": "nombre del profesional",

                "nomUsuario": "nombre del usu

3
0 963
Question James Hipp · Aug 7, 2019

Hello,

I am wondering the best way to disable a user account using this class in Cache (Security.Users).

https://cedocs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.c…

Example User Account = jhipp

Currently is Enabled

I know that we can use the auto-generated EnabledGetStored method, for example:

%SYS> w ##class(Security.Users).EnabledGetStored("jhipp")
1

There is not an auto-generated method to set this property, right?

I can modify this property with the Modify function, but I have to build a temp array with one value etc...

%SYS> s temp("Enabled")=0

%SYS> zw

4
0 526
Article Dmitrii Kuznetsov · Feb 4, 2020 16m read

When do implicit assumptions in code and arithmetic operators pose a real danger, and how can this danger be overcome?

Constantinople in the 5th century AD

(It was possible for people to build grandiose buildings and vehicles without the use of computers and robots 1,600 years ago.)

If you assign dimensionless numbers to physical parameters in your code, you risk misunderstandings and errors when calculating and converting between units of measurement. This applies to both composite units of measurement, such as those for energy, pressure, and power, as well as to the simple basic unit


4
0 605
Question Yone Moreno · Feb 6, 2020

Hello,

I would like to change signature's algorithm to be sha1.

I share the current code:

(BINARY SECURITY TOKEN and USERNAME TOKEN CODE omitted)

//SIGNATURE TOKEN
    set signSha1=##class(%XML.Security.Signature).%New()
    do signSha1.SetSignatureMethod($$$SOAPWSrsasha1)
    //..SetSignatureMethod($$$SOAPWSrsasha1)
    //$method(signSha1,"SetSignatureMethod",$$$SOAPWSrsasha1)
    //signSha1.SetSignatureMethod($$$SOAPWSrsasha1)
   set sig=signSha1.CreateX509(cert)

I have tried to use SetSignatureMethod, however in the Message Viewer we see:

As you see I have tried every other way I

1
0 177
Question Stella Ticker · Jan 31, 2020

I am trying to get a list of all settings for all the config items of a given production using SQL . When I run the following sql as a dynamic query I am unable to access the setting names and values. Settings is a list of Ens.Config.Setting

Set query="Select Name, Production, Settings,$ListLength(Settings) "
         _"As Count from Ens_Config.Item "

Set rc=##class(%ResultSet).%New()

Set sc=rc.Prepare(query)

Set sc=rc.%Execute

While rc.Next(.sc) {

For i=1:1:Count {

  Set tSetting=$List(Setting,i)

  Set name=tSetting.Name

}

I get a LIST error on the last line! Is it

4
0 964
Announcement Dmitry Maslennikov · Sep 9, 2019

Hi all, it's finally time for the next release of VSCode ObjectScript extension. So what's new in this release.

  • Debugging support, for classes, routines and attach to a running process
  • Files in Server Explorer now can be edited

  • Added more details about connection errors

  • Improvements in Server Explorer build tree

  • Fixed memory leak when exporting large amount of files
  • Server view can be opened in explorer as virtual file system with schema `isfs://`
  • Option to suppress popup information message about successful compile, ("objectscript.suppressCompileMessages": true)
  • Export, addCategory setting have more flexibility in naming category for exported items
  • Formatting for commands and functions, as Word, UPPER or lower
  • Some improvements in syntax highlighting
  • Some other small fixes
16
3 1787