#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 Thomas Carroll · Nov 12, 2016 4m read

Embedded SQL is a tool that allows us to execute SQL statements in Caché Object Script. For example, to select the name of a person with a particular SSN from the Sample.Person class we can do the following:

&SQL(SELECT Nameinto:tNameFromSample.PersonWhereSSN = :tSSN
)

The colon syntax is used to identify local variables, in this case tName and tSSN. Here, tSSN will be defined prior to execution and  tName  will be set during execution of the statement. &SQL indicates to our compiler that this is SQL syntax.

4
0 2090
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)
 

When I run the System Management Portal (Interoperability>Production Configuration)

1
0 60
Question Deák Tamás · Nov 23, 2025

Hello word!

I am new in this field and i am coming from the dot net and angular world.
So hello to everyone!

Im trying to understand the unit test in the vs code what is works in the community version at home (25.2).
I set the  ^UnitTestRoot to somewhere and setted the "unitest: enabled" setting in the settings.json file. 
But it is not work and can't run. Is't it scan? It is not a problem because i can run it dircetley with ##class(classname).RunTest() and it runs but doesn't contain anyting. The Restresult is exist but it is empty.
I think the system is does not understand that the test can find

0
0 60
Article Julio Esquerdo · Nov 21, 2025 1m read

Hi,

When we open a terminal in IRIS, we are entering the ObjectScript shell. Within this shell, we can execute IRIS commands, such as:

In other words, the ObjectScript command is executed in the current shell. But it's always good to remember that IRIS has other shells

  • SQL
  • Python
  • TSQL
  • MDX

One very interesting aspect is shortcuts. We can access these shells through their calls or via shortcuts, as shown in the table below:

Shell

Call

Shortcut

SQL

Do $SYSTEM.SQL.Shell()

:sql

Python

Do $SYSTEM.Python.Shell

:py

TSQL

Do $SYSTEM.SQL.TSQLShell()

0
4 105
Article Padmaja Konduru · Nov 21, 2025 1m read

Terminal Commands for Production:

  • Production Start, Stop, Update, Recover and Clean Production

Do ##class(Ens.Director).StartProduction(“ProductionName”)

Do ##class(Ens.Director).StopProduction()

Do ##class(Ens.Director).UpdateProduction()

Do ##class(Ens.Director).RecoverProduction()

Do ##class(Ens.Director).CleanProduction()

Abort Messages in the queue:

               d ##class(Ens.Queue).AbortQueue(“Component Name”)

Get InstanceName :

              W !,##class(%SYS.System).GetUniqueInstanceName()

Get Node Name:

              W  !,##class(%SYS.System).GetNodeName()

Terminate JobId :

   d

0
4 103
Article Vachan C Rannore · Nov 21, 2025 3m read

Hola amigo! 😊 Cómo estás hoy,

I would like to share a small part of my learnings from my first ever official project: POS/EDC machine integration with our billing system. This was an exciting challenge where I got hands-on experience working with APIs and vendors. 

How does a Payment Machine actually work?

It's simple, start by initiating/creating a transaction, then retrieve its payment status.

Here, initiate/create refers to POST method and Retrieve refers to GET.

0
2 122
InterSystems Official Raj Singh · Feb 27, 2023

I'm pleased to announce version 2.6.0 of the VS Code ObjectScript extension, containing a number of enhancements that make a developer's life easier. Some highlights are described below. As always, find the full list of modifications in the CHANGELOG, including many bug and vulnerability fixes.

Switch namespaces quickly

Thanks to @Olli Tanskanen at partner company JediSoft Oy for this enhancement! You can now switch namespaces from the Server Actions menu (when using client-side folders only).

Fast, asynchronous server-side search

This one requires InterSystems IRIS 2023.x and the proposed API

17
2 980
Article Alberto Fuentes · Mar 4, 2024 2m read

I would like to share with you a little trick to customize how messages are displayed in the Message Viewer. In particular, how you can display messages as JSON (instead of the default XML representation).

image

Messages are objects that are used to communicate interoperability productions components. In my example I have defined a message that later I serialize as JSON to send to an external API. This message is defined as a regular message and also as a %JSON.Adaptor so I can export / import directly to or from JSON.

Class interop.msg.DeviceOrderReq Extends (Ens.Request, %JSON.Adaptor)
{

Parameter
3
6 634
Article Muhammad Waseem · Feb 28, 2025 7m read

Hi Community, 
In this article, we will explore the concepts of Dynamic SQL and Embedded SQL within the context of InterSystems IRIS, provide practical examples, and examine their differences to help you understand how to leverage them in your applications.

InterSystems SQL provides a full set of standard relational features, including the ability to define table schema, execute queries, and define and execute stored procedures. You can execute InterSystems SQL interactively from the Management Portal or programmatically using a SQL shell interface. Embedded SQL enables you to embed SQL statements in your ObjectScript code, while Dynamic SQL enables you to execute dynamic SQL statements from ObjectScript at runtime. While static SQL queries offer predictable performance, dynamic and embedded SQL offer flexibility and integration, respectively.

8
5 544
Article Zion Amsalem · Nov 9, 2025 3m read

As a developer who uses Cache as DB for a couple of projects, I'm using REST API's every time, knowing how to consume a resource from REST API, in my opinion, it's crucial to know how to consume external REST Api's using %Net.HttpRequest because it enables integration with modern web applications and services, and it's a crucial skill for a backend developer who loves and uses Cache as a DB.

What and who is %Net.HttpRequest

its just a class but this is the proper way of making request outside of the framework, this is just a simple class who provide HTTP methods like GET, POST and PUT and all

0
1 108
Article Ashok Kumar T · Oct 20, 2025 11m read

What is XML?

XML(eXtensible Markup Language) is a flexible, text-based, andplatform-independentformat used to store and transport data in a well-structured way that is both human- and machine-readable. XML permits users to define custom tags to describe the meaning and organization of their data. For example: <book><title>The Hitchhiker's Guide</title></book>.

An XML document is self-descriptive and structured as a hierarchical tree of elements.Every document has a single root element that encapsulates all other content.

3
6 344
Article Rob Tweed · Feb 26, 2025 6m read

Introduction

My guess is that most IRIS developers create their applications using its native ObjectScript language or, if using an external language, then most likely using either Java, Python or perhaps C++.

I suspect that only a minority have considered using JavaScript as their language of choice, which, if true, is a great shame, because, In my opinion and experience, JavaScript is the closest equivalent to ObjectScript in terms of its ability to integrate with the IRIS's underlying multi-dimensional database. 

In this article I'd like to lay out the case for JavaScript as a first-class

1
2 370
Article Andrew Sklyarov · Nov 2, 2025 7m read

Over time, while I was working with Interoperability on the IRIS Data Platform, I developed rules for organizing a project code into packages and classes. That is what is called a Naming Convention, usually. In this topic, I want to organize and share these rules. I hope it can be helpful for somebody.

 

Disclaimer: This guide is a good fit for Interoperability projects.When you have integrations, data flows, when you use IRIS for ETL processes, etc.Overall, when your code is combined with Productions.

4
4 162
Question Aditi Gandhi · Oct 24, 2025

I am looking to view the contents of the request object I am sending from my Service into my BPL in Message Viewer. My request contains references to other defined classes.

Class bd.webapp.OutboundMessageRequest Extends (%Persistent, Ens.Request)
{

Property Metadata As bd.webapp.OutboundMessageRequestMetadata;Property MessageContent As%DynamicObject;
}



Class bd.webapp.OutboundMessageRequestMetadata Extends (%RegisteredObject, %JSON.Adaptor)
{

Property RegionSlug As%String;Property TenantSlug As%String;Property SystemSlug As%String;Property MessageId As%String;Prop
7
0 110
Article Evgeny Shvarov · Feb 13, 2022 2m read

Folks!

Recently I found several one-line long ObjectScript commands on DC and think that it'd be great not to lose it and to collect more!

So I decided to gather a few first cases, put in one OEX project, and share them with you!

And here is how you can use them.

1. Create client SSL configuration.

set $namespace="%SYS", name="DefaultSSL" do:'##class(Security.SSLConfigs).Exists(name) ##class(Security.SSLConfigs).Create(name)

Useful if you need to read content from an URL.

Don't forget to return to a previous namespace. Or add 

n $namespace

before the call.

23
8 1322
Article Robert Cemper · Oct 21, 2025 2m read

If you start with InterSystems ObjectScript, you will meet the XECUTE command.
And beginners may ask: Where and Why may I need to use this ?

The official documentation has a rich collection of code snippets. No practical case.
Just recently, I met a use case that I'd like to share with you.

The scenario:

When you build an IRIS container with Docker, then, in most cases,
you run the  initialization script  

iris session iris < iris.script 

This means you open a terminal session and feed your input line-by-line from the script.
And that's fine and easy if you call methods, or functions, or commands.
But

1
3 122
Question Jorge Gea Martínez · Oct 22, 2025

Hi,

I'm trying to run some scripting in Windows. I'm using an instance of the IRISHealth community. 

I'm just trying to run a simple sequence of commands so I can run irissession in a non-interactive mode, like:

irissession.exe IRISHEALTH -U "%SYS" < "myprogram.iris"

 

The contents of my program.iris are, for instance, these ones, to run an online backup:

set$namespace="%SYS"set cbk = "C:\Test1.cbk"set log = "C:\Test1.log"w$$BACKUP^DBACK("","F","MyBackup",cbk,"Y",log,"NOINPUT","Y","Y", 1000, "Test1")
HALT

The execution starts, but then gets completely hung, I see infinitely:

%SYS>
2
0 91
Article Vachan C Rannore · Sep 15, 2025 2m read

Starting out with ObjectScript, it is really exciting, but it can also feel a little unusual if you're used to other languages. Many beginners trip over the same hurdles, so here are a few "gotchas" you'll want to watch out for. (Also few friendly tips to avoid them)


NAMING THINGS RANDOMLY

We have all been guilty of naming something Test1 or MyClass just to move on quickly. But once your project grows, these names become a nightmare. 

➡ Pick clear, consistent names from the start. Think of it as leaving breadcrumbs for your future self and your teammates.


MIXING UP GLOBALS AND VARIABLES

Globals (^G

15
2 361
Article Robert Cemper · Oct 14, 2025 3m read

To better understand Streams in IRIS I'll start with a short

History

In the beginning (before IRIS), there was just basic access to external devices.
The 4 commands OPEN, CLOSE, READ, WRITE still work and are documented 
by  Introduction to I/O in detail.
Especially for files, this is a direct access to your actual file system.
You have to take care of any status or other signal in your code.  
Also, any code conversion or similar is up to you. 

Class %Library.File aka %File offers a large collection of methods and queries 
for standard operations on directories and files.
READ, WRITE is there but the

2
3 118
Question Scott Roth · Oct 13, 2025

I have a custom defined priority field that is being stored as a number type

<record name="LocalClinicalMeSHTerms" type="serial">
<field name="LocalClinicalExpertiseCodedValue" type="{CODETYPE}" codeFamily="HSPD" codeTable="LocalClinicalExpertise" codeScheme="{MASTER}"/>
<field name="LocalCliniclDisplayOrder" type="number"/>
</record>

However, within the overviewIndividual.cls form

				{
					"type": "HSPD.collection",
					"key": "LocalClinicalMeSHTerms",
					"hideExpression": "formState.lib.hideField(formState) && model.LocalClinicalMeSHTerms==''",
					"templateOptions": {
						"labe
0
0 56
Article Yuri Marx · Oct 9, 2025 4m read

The ObjectScript language has incredible JSON support through classes like %DynamicObject and %JSON.Adaptor.This support is due to the JSON format's immense popularity over the previous dominance of XML.JSON brought less verbosity to data representation and increased readability for humans who needed to interpret JSON content.To further reduce verbosity and increase readability, the YAML format was created.The very easy-to-read YAML format quickly became the most popular format for representing configurations and parameterizations, due to its readability and minimal verbosity.

1
1 106
Article Prasanth Annamreddy · Jan 29, 2025 1m read

This code provide the configured production items with enabled or disabled status.

Include (Ensemble, EnsUI, EnsUtil)

Class Test.ProductionConfig
{

ClassMethod GetConfigItems() As %Status
{
Set tStatement = ##class(%SQL.Statement).%New()
Set tSC = tStatement.%PrepareClassQuery("Ens.Config.Production","EnumerateConfigItems")
Write tSC,!
Write "ConfigItemName"," ","Enabled",!
#Dim exp As %Exception.SystemException
#Dim rset As %SQL.StatementResult
Set rset = tStatement.%Execute()
Write rset,!
Write rset.%SQLCODE,!
While rset.%Next() {
Try {
Set tConfigName = rset.%GetData(1)
Set tEnabled = rset.%GetData(3)
Cat

2
2 267
Question Gopal Mani · Oct 7, 2025

Hi Community,
I’m trying to execute a directory query in InterSystems IRIS using %SQL.Statement, but encountering an unexpected error.

Details:
The following command confirms that the directory exists:

Set dirPath="\\MYNETWORK_DRIVE\DFS-Shared_Product\GXM"
Write ##class(%File).DirectoryExists(dirPath)

It returns 1, meaning the path is valid and accessible.

However, when I try to execute this SQL query:

Set File=##Class(%SQL.Statement).%New()
Set Status=File.%PrepareClassQuery("%File","FileSet")
Set Result=File.%Execute(dirPath)
If Result.%SQLCODE {
    Write Result.%Message
}

I get the

3
0 96
Article Andrew Sklyarov · Oct 3, 2025 8m read

I was really surprised that such a flexible integration platform with a rich toolset specifically for app connections has no out-of-the-box Enterprise Service Bus solution. Like Apache ServiceMix, Mule ESB, SAP PI/PO, etc, what’s the reason? What do you think? Has this pattern lost its relevance completely nowadays? And everybody moved to message brokers, maybe?

Wiki time: An enterprise service bus (ESB) implements a communication system between mutually interacting software applications in a service-oriented architecture (SOA) ...

0
1 133
Article Raef Youssef · Oct 2, 2025 5m read

Why This Matters

Managing IAM can be tedious when done manually — especially when your APIs are already well-documented using OpenAPI (Swagger) specs. Wouldn't it be great if you could automatically generate Kong services and routes directly from your OpenAPI spec?

That's exactly what this ObjectScript method does: it reads an OpenAPI 2.0 spec stored in the XData block of your spec class and generates a decK-compatible YAML file that can be used to sync your IAM configuration.

This approach:

  • Reduces manual configuration errors
  • Keeps your gateway in sync with your API spec
  • Speeds up deployment
0
2 99