#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.

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
5
0 737
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.

2
0 880
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
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 )

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.

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.
9
0 1203
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"}}}
6
0 1889
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? 

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 326
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 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 1153
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",

3
0 962
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 temp

temp("Enabled")=0

4
0 526
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 could think.

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

}
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 1786
Question Lucas Bourré · Jan 30, 2020

Hello,

I am working on Ensemble 2017.2.1 .
I need to export my security settings into an extern database, in order to make a report.

I've created a Business Operation with an SQL Adapter into a Namespace, but I don't know how to get every security data from "%SYS" Namespace  ( SQLPrivileges , Resources , Roles , Services , Users ... ).

I dont't want to use the terminal and the ^SECURITY routine, because i don't want to store a XML file on the server.

2
0 405