#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 Colin Brough · Feb 13, 2024

Does the GetValueAt method of an EnsLib.HL7.message object change the contents of the HL7 message?

We want to do two things, given an incoming HL7 message, in our production:

  • transform the HL7 to XML, where the class TNHS.Utils.HL7toXML provides the same methods as, for example, EnsLib.HL7.Util.FormatSimpleXMLv2:
    set sc = message.OutputToLibraryStream(xmlstream,"","","TNHS.Utils.HL7toXML")

     

  • extract a value from a particular field in the message: 
    Set ReportId = message.GetValueAt("PIDgrpgrp(1).ORCgrp(1).ORC:3.1")
3
0 526
Question Alex Baumberg · Feb 5, 2024

Hi all,

I'm very new to this ecosystem so please bear with me:

I've startted learning online and have installed everything I need. I have VS code and I have most definitely installed the pack (3 packages) needed for working on it with ObjectScript. Even though this is the case I'm running into 2 problems:

1. when I type "class" I only get 4 option for auto complete. no "class with multiple inheritances" or anything of the sort. In fact, no Class at all, only ClassMethod. ClassResponse etc.

3
0 375
Article Elijah Tamarchenko · Feb 8, 2024 2m read

Interacting with Users in the Terminal: A Guide to Using %Library.Prompt in IRIS

 

Have you ever wondered how commands like ^DATABASE engage users in the terminal? Or perhaps you're writing an automation routine and want ways to specify options directly from the terminal. Thankfully, the %Library.Prompt class in IRIS offers a straightforward way to do so!

String Input

For basic input, such as asking the user to provide a filepath or namespace, use the following code:

set status = ##class(%Library.Prompt).GetString("Input filepath:", .path)
2
3 392
Question Kurro Lopez · Feb 7, 2024

Hi community.

Yes, I know that there is other question "VS Code - debugging doesn't work" that is the same issue, but my IRIS instance is not using IIS.

Some times ago, I could debug without problems, but after some updates of Visual Studio, I get the following error

Failed to start the debug session. Check that the Intersystems server's web server supports WebSockets

I've activated the WebSocket protocol in the server (Windows Server 2019) but it still doesn't work.

The IRIS instance is not using IIS, I think it is using the Apache by default.

Do I need to do anything in special?

3
0 303
Article Sylvain Guilbaud · Feb 1, 2024 5m read

Hello Community,

SQL language remains the most practical way to retrieve information stored in a database.

The JSON format is very often used in data exchange.

It is therefore common to seek to obtain data in JSON format from SQL queries.

Below you will find simple examples that can help you meet this need using ObjectScript and Python code.

ObjectScript : using Dynamic SQL with %SQL.StatementJSON structures with %DynamicObject and %DynamicArray

1
4 567
Question Kari Vatjus-Anttila · Jan 25, 2024

Hello,

How can I send a request via a SOCKS5 proxy in IRIS, using, for example, EnsLib.REST.Operation?

Background

I need to access APIs inside my corporate network, to which I don't have direct access from my home office. I've set up a SOCKS5 proxy via SSH on my host machine like this:

ssh -D 9999 server.corporate.com

I can then make requests with curl to the APIs I need:

curl -x socks5h://localhost:9999 https://api.corporate.com/api/some/endpoint

And I receive a response. Simple!

Also, inside the containerized IRIS, I can execute the request:

2
0 357
Question Mathew Rimmington · Jan 24, 2024

In VS Code using the InterSystems ObjectScript extensions, I'd like the indentation applied to match that of IRIS Studio. Specifically for comments and dot syntax, I'd like pressing enter (carriage return) to preserve the current dot depth and same comment beginning.

In IRIS Studio after changing the indentation settings to custom using " \t.#/;" without quotes (note the leading space), the behaviour looks like this:

And after pressing enter the leading comment is preserved:

For dot indented code:

After pressing enter the dot depth is preserved:

3
0 513
Question Emil Odobasic · Dec 20, 2023

Hello everyone!
I am wondering how I can retrieve multipart form-data from a request that is coming into my REST-service.
I am supposed to retrieve a string and a file. The file is being retrieved without issues, but the "testprofile" string is not being retrieved at all.
It just logs a an empty entry. 
The request that is sent to my REST-service has the Content-Type: multipart/form-data
Thanks beforehand for the help! :)

Down below is the code I use right now to retrieve the string and file from Form-data Rest HTTP-request to my service.

5
0 936
Question Emil Odobasic · Jan 8, 2024

Hello everyone!
I am receiving a HTTP multipart/form-data request into my rest service.
How can I read the values for each Key in the form?
The key "Profile" is sent to my service as a String data type.
The code I have below does not seem to work, where I try to read the Key profile in the form.

I appreciate all the help I can get! :)

26
0 913
Article Lorenzo Scalese · Nov 10, 2023 13m read

Hi, developers!

Currently, I'm working on a project that requires highly dynamic event management. In the context of the Java programming language, my first instinct should be to opt for the "Observer Pattern", which is an approach to managing interactions between objects by establishing a notification mechanism. It allows multiple observers to react to changes in the state of a subject autonomously, promoting code flexibility and modularity. If you are not familiar with this design pattern, check out Wikipedia to find more information about it.


While it's natural and commonly used in certain programming languages as Java and C++, in ObjectScript, it's quite a different story.

3
5 979
Article David Hockenbroch · Jan 4, 2024 22m read

So far, we have covered how to use ObjectScript to manage users, roles, resources, and applications. There are a few other classes in this package that work similarly to the ones mentioned above. However, these four classes are the ones everyone will have to use to manage their application security. Suppose you wanted to create your own Security management portal for this package. There would be some specific issues to think about for an API. Since the classes use similar methods, we can create fewer API endpoints using indirection. However, we should consider differences between those methods

2
3 471
Question Joseph Griffen · Jan 19, 2024
I'm wondering what the best practice is for handling %Status values within the terminal.
1. set tSC=...
    do $SYSTEM.Status.DisplayError(tSC)
2. set tSC=...
   zwrite tSC

3. An alternative?

Is there a meaningful difference between the two? Should one be used over the other for any reason? Should something else be used?

2
0 254
Question Prasanth Annamreddy · Oct 24, 2023

We are running Batch job in scheduled task and the messages are picking in single session and it is not easy to trace the record.

I used the Set ..%SessionId= "" at before sending the message to BP but I see the session Id is '1' created for each message.

Is there anyother way to create new session for each message sending to BP?

Thanks,

2
0 481
Question Scott Roth · Jan 11, 2024

I am trying to write a ZMIRROR routine that makes a shell script call using $ZF

Set cmd = "/usr/local/sbin/failover-intengtest-vip"Do$ZF(-100,"/ASYNC /SHELL",cmd)

The script I am calling is returning an output to the screen, how do I get around this using $ZF without having to rewrite the scripts?

Thanks

Scott

2
1 251
Discussion Stefan Cronje · Dec 15, 2023

Hi all,

The last time I used CSP was back in 2008, so I am very rusty on it.
This question might have been asked many times, and the answer probably is that it is a matter of preference.

Are there scenarios to which CSP pages is easier/better to use than classes extending from %CSP.Page?
I want to build a little thing and don't want to start at the wrong end.
Doing an API-based, heavy client-side framework is not a requirement, and I would prefer not to do it that way.

Some of the criteria

4
0 385
Question Stefan Cronje · Dec 15, 2023

HI *,

So last night I was doing a deployment which had a query to select from a large dataset of joined tables, to iterate through and populate data in a new table.

This was done in a classmethod using embedded SQL and the %PARALLEL keyword.
On a testing environment with the same dataset, this worked perfectly a few days earlier.

2
0 331
Question Sandeep K C · Jan 10, 2024

Hello Guys,

Our cache application uses REST web services and handles single API request perfectly with response (response status and related data). But sometimes user sends multiple requests to the same API simultaneously ( ie, without waiting for the first to respond ), where one request will succeed (not necessarily the first) and the others will fail. 
So, I need to handle the requests one by one after completing and sending the response for first request in the queue then process the next request and so on.

Is there any appropriate way of handling this problem? 

4
0 461
Article Jose Ruperez · Oct 11, 2016 4m read

Now, let’s say you can’t access the terminal or simply you just rather execute it from a web interface. In this article, I will show you how to execute terminal commands from a simple web page.

For example, in the image below you see how we execute $zv on a webpage:

This is mostly possible due to the XECUTE command in Caché ObjectSCript. This command takes a string as a parameter and tries to execute it. This is the command used from the webpage, to execute what is being passed from the left navigation menu.

7
0 32720
Question Stephane Devin · Dec 14, 2023

I got a problem to resolve, to sum it up I need to extract a function body from a JS file with cos.
I already got the JS code in a string and the function name but I'm kinda stuck as to how to get my function body, I already tried a few things (regEx, counter bracket) but there are comment and strings that block them from functioning. Is there a javascript parser or a good way to do it except by creating a javascript parser?

8
0 579
Question Stefan Cronje · Dec 21, 2023

Hi,

The system I am working on processes large numbers of records. Inserts, updates and so forth. There are multiple processes that can potentially work on the same table at the same time. 

It is an almost impossible task to try and time these processes to not run at the same time, due to volumes, SLAs, etc.

Every now and then there are a few locking issues, Not many considering the volumes. It is just a bit of a nuisance as we need to reprocess these records later.

All the selects on the processes run at IsolationMode 0 and the transactions are kept as short as possible.

6
0 422
Question Emil Odobasic · Nov 29, 2023

Hello everyone!
Sorry for the vague title! But I wonder what would be the best way to easily import a large XML-file into a production, modifying it by deleting elements and nodes depending on what values are in those nodes/elements and later creating whole new XML-file from that?

I have gone through this: Using Caché XML Tools | Caché & Ensemble 2018.1.4 – 2018.1.8 (intersystems.com)

But I get the sense that there are a lot of ways of approaching this, but I do not know what is the most effective for my certain needs.

I appreciate the help! Thanks beforehand! :)
 

5
0 540