#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 Evgeny Shvarov · Jan 4

Hi Developers!

Sometimes we need to deal with classes/tables where the primary key and the IdKey are something that is maintained by yourself.

What is the proper way to generate a new ID in case where ID is a %BigInt?

Property id As %Library.BigInt

Are there any system methods to provide it?

There is data already imported via SQL, so there is no last ID stored in ^myclassD, so I cannot do $I(^myclassD).

Thinking of:

set newid=$O(^myclassD(""),-1),newid=$I(newid)

What do you think?

34
0 203
Question Scott Roth · Jan 2

Defining my first REST API within InterSystems using iris-rest-Api-template as a basis and I am seeing if someone could provide me some guidance to see if I can make it work.  

In some of my other posts, I have been trying to come up with a way for our Enterprise Application Development team which works with .Net to build Applications to make a REST call to our instance of InterSystems to query some of the Cache Tables we have defined. 

Using the iris-rest-api-template, I have created the osuwmc.DataLookup.REST.Base.cls

4
0 79
Question Scott Roth · Jul 14, 2025

I have been struggling sometime with trying to take a FHIR Bundle Response, extract the "entry.resourceType", extract the MRN and Name from the Patient FHIR Response...

Going through learning.intersystems.com, it suggested that I try using fhirPathAPI to parse and search my response for certain values, however I am not sure my syntax is correct. Using the AI code, it suggested to set my tree = "Bundle.entry.resource.resourceType"

1
0 115
Question Evgeny Shvarov · Dec 29, 2025

Hi Developers!

Consider I have a persistent class derived from %Persistent and I want it to be derived from %JSON.Adaptor to enjoy all the JSON features.

Can I do it programmatically? 

So, it'd be wonderful to have a method in some util class that makes it happen? Something like:

Do ClassUtil.AddAncestor("MyPackage.MyPersistentClass","%JSON.Adaptor")

Any ideas?

6
1 99
Article Thibault Odor · Dec 29, 2025 3m read

You probably know this situation:
Some time ago, you found a very special $ZU function for a very specific type of problem. Some kind of mystical formula. It became popular and was used by many developers throughout your code and across all your installations.

Several versions and updates later, you are informed by ISC that your mystical $ZU is deprecated and no longer supported. You are advised to replace it with a new $something().

2
0 109
Article Keren Skubach · Dec 29, 2025 2m read

When working with InterSystems Interoperability (Iris / Health Connect / Ensemble), configuration data is often spread across many production items: services, processes, operations, adapters, and their settings.

A common operational or security need is to answer questions like:

  • Which interfaces reference file system paths?
  • Where are directories, network shares, or absolute paths configured?
  • Can I quickly audit or document this information across all my productions?

The ObjectScript utility below solves exactly that problem by exporting selected configuration settings into a CSV file.

0
2 98
Question Jonathan Harris · Dec 24, 2025

Here is what is currently used.

..CurrentDateTime("%Y%m%d%H%M%S")

The format is not the issue.

I need to make it our current time as it is five hours ahead.

How can I access the header property of either of these.

Or, if I can't do that, subtract five hours or the equivalent time in seconds.

example, if I receive 20201224161922, how can I make it 20201224111922?

Thanks,

Jonathan

3
0 74
Article Ashok Kumar T · Dec 28, 2025 3m read

Embeddedpy-bridge: A Toolkit for Embedded Python

Overview

Embedded Python is a game-changer for InterSystems IRIS, offering access to the vast Python ecosystem directly within the database. However, bridging the gap between ObjectScript and Python can sometimes feel like translating between two different worlds.

To make this transition seamless using embeddedpy-bridge.

1
2 88
Question Evgeny Shvarov · Dec 28, 2025

Hi developers!

There is a neat feature of ObjectScript classes - Query element, which allows you to write in a clear SQL (without any & or ()), pass parameters to it and call it from ObjectScript as do QueryNameFunc() or via Call SQLProcedureName via SQL, .e.g.

Query MyQuery(p as%String) as%SQLQuery [SQLProc]

{ 

SELECT * FROM MyTable 

WHERE Name=:p

}

All works fine, but when I tried to use the same for a DELETE statement see the following error:

SELECT expected, DELETE found ^ DECLARE Q1 CURSOR FOR DELETE

Is the Query element for SELECT only? What am I doing wrong? )

4
0 70
Question Evgeny Shvarov · Dec 26, 2025

Hi developers!
Happy holidays!

In ObjectScript there is neat option to log errors - call Log() method of an exception intance, e.g.:

ClassMethod MyMethod() {

Try {

w1/0

}

Catch e {

do e.Log() // logging error in the app logwrite"the error happened: "_e.DisplayString()

}

}

Is there anything like that for Embedded Python? e.g:

ClassMethod MyMethod() [Language = python] {

 try:

   print(1/0)

 except ZeroDivisionError as e:

   // how can I log e into IRIS App Error Log here?

   print("Caught exception: " + str(e))

}

Any ideas?

8
0 89
Article Vachan C Rannore · Oct 21, 2025 3m read

Hello!!!

Data migration often sounds like a simple "move data from A to B task" until you actually do it. In reality, it is a complex process that blends planning, validation, testing, and technical precision.

Over several projects where I handled data migration into a HIS which runs on IRIS (TrakCare), I realized that success comes from a mix of discipline and automation.

Here are a few points which I want to highlight.

1. Start with a Defined Data Format.

Before you even open your first file, make sure everyone, especially data providers, clearly understands the exact data format you expect. Defining templates early avoids unnecessary bank-and-forth and rework later. 

While Excel or CSV formats are common, I personally feel using a tab-delimited text file (.txt) for data upload is best. It's lightweight, consistent, and avoids issues with commas inside text fields. 

PatID   DOB Gender  AdmDate
10001   2000-01-02  M   2025-10-01
10002   1998-01-05  F   2025-10-05
10005   1980-08-23  M   2025-10-15

Make sure that the date formats given in the file is correct and constant throughout the file because all these files are usually converted from an Excel file and an Basic excel user might make mistakes while giving you the date formats wrong. Wrong date formats can irritate you while converting into horolog.

12
2 225
Article José Pereira · Dec 7, 2025 16m read

Project Overview / Introduction

Developing and testing REST APIs in InterSystems IRIS often requires a significant amount of boilerplate code. While ObjectScript provides powerful tools for building APIs, writing consistent and repeatable tests can be time‑consuming. This is where IrisOASTestGen comes in.

2
0 107
Article Dmitrij Vladimirov · Dec 1, 2025 5m read

In this article, we will discuss all the debugging tools included in the Microsoft Visual Studio Code IDE.

What will be covered:

  • Breakpoints
  • Watch window
  • Call Stack

Let's start by learning about debugging requirements!

Prerequisites

There are two plugins (extensions) for debugging ObjectScript:

The first is part of the InterSystems ObjectScript Extension Pack. The second is Serenji, a standalone plugin that provides an editor, file manager, and debugging functionality. Both plugins can be installed from the plugin store. To activate key functionality, Serenji requires a license. For this article, we'll use the InterSystems ObjectScript Extension Pack to reduce the learning curve. After you've mastered the basics, you can consider purchasing a paid license for Serenji.

2
5 270
Article Megumi Kakechi · Dec 18, 2025 1m read

InterSystems FAQ rubric

If you try to kill a global that is mapped at the subscript level from the top node, you will get a <SLMSPAN> error and it will not be deleted. This is because the kill command for subscript-level mapped globals cannot be used across mappings.

// Suppose subscript-mapped globals exist in different databases, as shown below:^TEST(A*~K*) -> database A
^TEST(L*~Z*) -> database B

// Trying to kill from the top level will result in a <SLMSPAN> error.
NAMESPACE>Kill^TEST
<SLMSPAN> <- This error is output.
0
0 74
Question Scott Roth · Dec 17, 2025

Using a Workflow Task within HealthShare Provider Directory, when a user clicks on Resubmit message within my Business Process, I check the status of the response. If the response is "Resend Message", I have my Business Process executing the following...

set tSC = ##class(Ens.MessageHeader).ResendDuplicatedMessage(context.SessionID)
 if$$$ISERR(tSC) $$$LOGSTATUS(tSC)

the context.SessionID is the Session ID of the message as it is being pass thru the Business Process. Does anyone see why that would not work off hand?

3
0 57
Article José Pereira · Dec 9, 2025 11m read

The previous article introduced IrisOASTestGen, a tool designed to generate REST API test code for InterSystems IRIS based on OpenAPI 2.0 specifications. It demonstrated how to scaffold test cases using the default templates bundled with OpenAPI Generator.

This follow-up focuses on the next natural step: customizing the generated test code. By extending the code generation logic with Mustache templates, it becomes possible to express richer semantics, implement CRUD-aware tests, and create more meaningful test suites.

0
0 66
Question Marco Bruni · Nov 28, 2025

Hello!I have the following XML document obtained through a string:<?xml version="1.0" encoding="UTF-8" standalone="yes"?><MainDocument xmlns="urn:hl7-org:v3"><realmCode code="IT"/><title>kjbkjkjbkjb</title><effectiveTime value="20090905150716"/>[.....other tags.....]<versionNumber value="1"/><component><body>mhvjhjkvhj</body><component><section>content</section><ID>5</ID><title>Certificato</title><text/><entry><Id>5</Id>[...other tags...]</entry><entry><Id>6</Id>[...other tags...]</entry></component></component></ClinicalDocument>I would like to have a way to obtain only the content of the

7
0 102
Article Ashok Kumar T · Nov 10, 2025 2m read

FastJsonSchema: High-Performance JSON Validation in IRIS

Validating JSON data against JSON Schema is a common requirement for modern applications. FastJsonSchema brings this capability natively to InterSystems IRIS, combining speed, simplicity, and full schema compliance.

Unlike traditional validation approaches, FastJsonSchema generates native ObjectScript code from your JSON Schemas and compiles it directly to iris object code, enabling idiomatic performance without relying on external libraries or runtimes.

1
0 85
Article David Hockenbroch · Dec 4, 2025 6m read

InterSystems IRIS provides extensive configurable security options, yet many developers primarily use roles and resources to secure entire tables or routines. Today, we will delve deeper. We can also secure individual columns and rows separately, but these two mechanisms operate very differently. Let's begin with the columns.

Column Security

For testing and demonstration, we will keep our table structure concise and straightforward. We have a table called "Person" in the USER namespace that contains an ID column, a date of birth column (DOB), first name, and last name. 

0
1 221
Article Timothy Leavitt · Dec 4, 2025 2m read

There's a pattern I've encountered several times where I need to use a temp file/folder and have it cleaned up at some point later.

The natural thing to do here is to follow the patterns from "Robust Error Handling and Cleanup in ObjectScript" with a try/catch/pseudo-finally or a registered object to manage cleanup in the destructor. %Stream.File* also has a "RemoveOnClose" property that you can set - but use with care, as you could accidentally remove an important file, and this flag gets reset by calls to %Save() so you'll need to set it back to 1 after doing that.

There's one tricky case, though - suppose you need the temp file to survive in an enclosing stack level. e.g.:

0
0 85
Article Timothy Leavitt · Jan 15, 2020 9m read

Introduction and Motivation

A unit of ObjectScript code (a ClassMethod, say) may produce a variety of unexpected side effects by interacting with parts of the system outside of its own scope and not properly cleaning up. As a non-exhaustive list, these include:

  • Transactions
  • Locks
  • I/O devices
  • SQL cursors
  • System flags and settings
  • $Namespace
  • Temporary files
8
6 1659
Article Luis Angel Pérez Ramos · Mar 11, 2025 53m read

Since the introduction of Embedded Python there has always been doubt about its performance compared to ObjectScript and on more than one occasion I have discussed this with @Guillaume Rongier , well, taking advantage of the fact that I was making a small application to capture data from public competitions in Spain and to be able to perform searches using the capabilities of VectorSearch I saw the opportunity to carry out a small test.

Data for the test

Public tender information is provided monthly in XML files from this URL  and the typical format of a tender information is as follows:

7
3 417
Question Phillip Wu · Nov 23, 2025

Hi,

I want to get the status of a Production (Running, Stopped), Queue length, Time the Production started

I did this:

>zn "test"
>set status=##class(Ens.Director).GetProductionSummary(.pinfo)
>write status
1
>zwrite pinfo
pinfo("PKG.FoundationProduction")=$lb("Stopped","","",0)
pinfo("Report.Print.EnsemblePrintService")=$lb("Stopped","2021-02-09 23:15:57.538","2021-02-09 23:16:15.264",0)
pinfo("TC.hmf.Production")=$lb("Stopped","","",0)
pinfo("TC.hmf.System.Production")=$lb("Running","2025-10-30 10:18:24.057","",1)
 

1
0 59