#JavaScript

0 Followers · 129 Posts

JavaScript, often abbreviated as JS, is a high-level, interpreted programming language. It is a language which is also characterized as dynamic, weakly typed, prototype-based and multi-paradigm.

Learn more.

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. 

1
2 270
Article Eric Fortenberry · Oct 7, 2025 3m read

While working with external languages for IRIS (such as Python and Node.js), one of the first things you must accomplish is making a connection to an IRIS instance.

For instance, to make a connection in python (from https://pypi.org/project/intersystems-irispython/):

import iris

# Open a connection to the server
args = {
	'hostname':'127.0.0.1', 
	'port': 1972,
	'namespace':'USER', 
	'username':'username', 
	'password':'password'
}
conn = iris.connect(**args)

# Create an iris object
irispy = iris.createIRIS(conn)

# Create a global array in the USER namespace on the server
irispy.set("myGlobal", "hello world!") 

To establish a connection, you must either hard-code connection information in your script or you must prompt the user for the information.

To help manage these IRIS connections in my own projects, I created irisconns on Open Exchange.

irisconns allows you to decouple your connection information from your project/code by allowing you to save that connection information into files that are separate from your code. (Think "DSN" and "ODBC" for your IRIS Native SDK connections.)

Getting Started

To get started with irisconns, create either an irisconns or .irisconns file in your project's working directory, any parent directory to your working directory, or your home directory. Populate your irisconns file with connection information in an INI file format:

# 'default' is the connection returned if no name is provided.
[default]
hostname = localhost
port = 1972
namespace = USER
username = _SYSTEM
# confirm password? true or false?
confirm = false

# This connection name is "TEST".
[TEST]
hostname = test-server
port = 1972
namespace = USER
username = _SYSTEM
# confirm password? true or false?
confirm = false

# This connection name is "PROD".
[PROD]
hostname = prod-server
port = 1972
namespace = %SYS
username = _SYSTEM
# confirm password? true or false?
confirm = false

You will also need to copy the associated irisconns.py or irisconns.js libraries into your project so that you can import the irisconns module from your code. (Currently, only Python and Node.js libraries exist.) You also need to install the IRIS native packages for your programming language:

# Install Dependencies for Python
cp /path/to/irisconns/irisconns.py ./irisconns.py
pip install intersystems-irispython

# Install Dependencies for Node.js
cp /path/to/irisconns/irisconns.js ./irisconns.js
npm install @intersystems/intersystems-iris-native

Using "irisconns"

Once installed, you should be able to use/prompt for your connection configuration:

# Python Connection Example
import irisconns

# default connection
irispy = irisconns.get_irispy()

# named connection
irispy = irisconns.get_irispy('TEST')

# usage
irispy.set('hello world!', 'test', 1)
// Javascript Connection Example

// Import the package
const irisconns = require('./irisconns.js');

// Wrap in an async function so we can await the connection...
(async () => {
  // 'default' connection
  const iris = await irisconns.get_iris();

  // named (i.e. "PROD") connection
  // const iris = await irisconns.get_iris('PROD');

  // usage
  iris.set('hello world!','test',1);
})()

The above code will produce prompts, similar to the following:

# Connecting to default
Hostname    : localhost (default)
Port        : 11972
Namespace   : USER (default)
Username    : _SYSTEM
Password    : [hidden]
Confirm     : [hidden]

Closing

You can find more information about irisconns on the Open Exchange page. Hopefully you will find it useful!

Thanks!

0
0 33
Question David Saunders · Sep 4, 2025

Given the code below, I need help with getting the collected column widths from the Demo.Configuration table and stored in the columnWidths zne page property. As I understand it, I should be able to retrieve it using zenPage.columnWidths in the setColumnWidths or dgRender clientMethods but the alert is showing that it cannot be retrieved as it shows a value of Null. Once I can retrieve those values, then I want to set the widths of the colmns of the dynaGrid according to the values in the ^Demo.Configuration table. The data pulled in from the CSV file that creates ^Demo.Import can have a

2
0 45
Question David Saunders · Aug 12, 2025

I am trying to use upload.csp as a template for choosing a CDV file to process. I am calling it from a zen page using this:
<button caption="Import Client Consultation Extract" 
       controlStyle="width:500px; height:100px; font-size:1.5em;"
         onclick="zenPage.importExtract();"/>

ClientMethod importExtract() [ Language = javascript ]
{
    // Open CSP popup to upload the CSV
    //alert('importExtract called.');
    zenPage.launchPopupWindow(zenLink('Upload.CSP'),'Upload Client Consultation extract',
                              'status,scrollbars,resizable,width=750,height=250');
}

8
0 95
Question Aaron Laferty · Aug 14, 2025

Hi all,

I’m running into an issue with a %ZEN.Component.tablePane in a Zen page.

We have:

  • A fully styled table with all columns defined
  • A backend query (SearchMessages) that accepts multiple filter parameters
  • A set of input fields at the top of the page for filtering (text, date, and checkboxes)

We’re trying to run the query from a button click using a client-side method (runSearch()) that collects the filter values, sets them as parameters, and calls executeQuery().

0
0 48
Article Dmitry Maslennikov · Jul 28, 2025 5m read

Overview

The typeorm-iris project provides experimental support for integrating TypeORM with InterSystems IRIS, enabling developers to interact with IRIS using TypeORM’s well-known decorators and repository abstractions. This allows a more familiar development experience for JavaScript and TypeScript developers building Node.js applications with IRIS as the backend database.

TypeORM MongoDB Review. I recently started using TypeORM in a… | by Eliezer  Steinbock | Medium

While the project implements key integration points with TypeORM and supports basic entity operations, it’s not yet battle-tested or suitable for production environments.

10
1 207
Article Harshitha · Aug 3, 2025 2m read

Working in healthcare IT as a young developer, especially on InterSystems TrakCare, you quickly realize one thing: it’s not just about HL7 messages or backend integrations. A hugepart of making TrakCare work smoothly for hospitals comes down to how it’s configured, customized, and supported on the application side.

That’s where people like me come in—techno-functional developers who understand both the tech and how it impacts actual hospital workflows.

We’re Not Just Techies (or Functional Consultants)

Our role sits right in the middle. We're the ones:

1
2 77
Question Ronaldo Nascimento · Jul 22, 2025

Working on wrapping an IRIS Cache ObjectScript method that runs for a few seconds. Trying to get UI updates to show BEFORE the method runs in an async/await function. But it seems to be running synchronously rather than asynchronously . So my question is does IRIS/ObjectScript CSP pages support futures with JavaScript or does it run all synchronously.

2
0 84
Question Ward De Backer · Oct 26, 2022

Hi,

If I test the Native api for Node.js from the documentation, I noticed (if I'm correct) all methods and calls are synchronous. By default due to the nature of Node.js, there is only one thread of execution and normally  all JavaScript methods and all calls should be asynchronous and use either a callback function (the "old way") or promises or the async/await contruct to return their result, e.g.:

  • myFunction(params, callbackFunction(response))
  • myFunction(params).then(resolveFunction(response))
  • async someFunction() {
    ​​​​​  response = await myFunction(params)
    }
15
0 806
Question Harshitha · Jul 1, 2025

Hi everyone,

I'm working with JavaScript in InterSystems IRIS, specifically in CSP pages. One issue I'm running into during development is that the browser keeps loading the cached version of my JavaScript files, even after I’ve made changes or recompiled the code.
I would have to clear my cache files or browser history for it to reload and work.

2
1 110
Article Alex Alcivar · Jul 28, 2024 6m read

For a long time I have wanted to learn the Django framework, but another more pressing project has always taken priority. Like many developers, I use python when it comes to machine learning, but when I first learned web programming PHP was still enjoying primacy, and so when it was time for me to pick up a new complicated framework for creating web applications to publish my machine learning work, I still turned to PHP. For a while I have been using a framework called Laravel to build my websites, and this PHP framework introduced me to the modern Model-View-Controller pattern of web

2
1 376
Question Michael Davidovich · Apr 10, 2025

Hello,

Our software commonly returns a full result set to the client and we use the DataTables plugin to display table data.  This has worked well, but at datasets grow larger, we are trying to move some of these requests server-side so the server handles the bulk of the work rather than the client.  This has had me scratching my head in so many ways.  

I'm hoping I can get a mix of general best practice advice but also maybe some IRIS specific ideas.

Some background

6
0 152
Question John McBride · Mar 4, 2025

Hello, Does the NodeJs package work when running a node js file on windows (nodejs for windows)? I've added the package by running npm install <package location folder>

I have the following index.js file, but when running from node (windows) I get the following error. Does the NodeJs package build the output files when the package is added or does it just assume linux as the underlying os?

Error: Cannot find module './bin/winx64/irisnative.node'

5
0 114
Question Dan Murt · Jan 3, 2025

Hi Community,

I have a CSP page I am developing with the intent of pulling files from an SFTP site and placing them in a folder on the local network.

I am having an issue where the CSP page is catching a JS error. The error in the browser is - A JavaScript exception was caught during execution of HyperEvent: SyntaxError: Unexpected identifier 'downloading'. (However, the unexpected identifier changes after refreshing page, or after removing the Write statement with the work 'downloading' in it.)

I think I have narrowed it down to a piece of the Javascript code - 

9
0 228
Question omer · Nov 24, 2024

I am working on a product that uses REGEX and matches it. 
The regex is tested both on the client-side (using the JavaScript REGEX engine) and both on the server-side.
But I couldn't find one word about the way intersystems parses the regex, It is quite elementary to state which which engine it works with. 
from what I could gather from early implementations and such, the engine is based off PCRE, But I need to confirm this somehow, Can anyone give me a definitive answer, Is there any tool to test the regex other than writing it myself??
 

2
0 185
Article Andrii Mishchenko · Sep 22, 2024 5m read

Introduction

Managing databases and performing CRUD operations are fundamental tasks for developers building data-driven applications. While many database management systems (DBMS) exist, they can be complex and cumbersome to interact with, especially when it comes to creating databases and tables, handling constraints, and performing real-time data operations through an API.

4
0 355
Article Andrii Mishchenko · Sep 27, 2024 4m read

In this article, we’ll dive into the inner workings of the database management tool, exploring the architecture and technologies that power it. Understanding how the application functions behind the scenes will give you insight into its design, how it manages databases, tables, and how the API interacts with data.

We will discuss the core technologies used, including InterSystems IRIS as the primary database and Redis for caching. Additionally, we’ll break down the structure of the tables used and explain how the system handles data creation, retrieval, and manipulation through the REST API.

0
1 207
Question Mark OReilly · Jul 31, 2024

Hi:

I have been adapting the IRIS WHIZ addon as part of the contest. I will soon fork the code on github so the changes are available. 

The next phase is I am storing the date from and to time for a more complete search cache 

zenPage.getComponent(36).value

it works in the chrome console ok 

I'm not sure in external JS how to set the page it is on as a zenpage to use the zenpage functions

3
0 142
Article Alex Alcivar · Jul 27, 2024 7m read

I received some really excellent feedback from a community member on my submission to the Python 2024 contest. I hope its okay if I repost it here:

you build a container more than 5 times the size of pure IRIS

and this takes time

container start is also slow but completes

backend is accessible as described

a production is hanging around

frontend reacts

I fail to understand what is intended to show

the explanation is meant for experts other than me

The submission is here: https://openexchange.intersystems.com/package/IRIS-RAG-App

2
3 465
Question Alin Soare · May 30, 2024

Hi, 

I almost managed to connect myself from nodejs to IRIS via intersystems-iris-native, but the connection failed. 

> const irisnative = require('./intersystems-iris-native')
> irisnative
{
  createConnection: [Function (anonymous)],
  Connection: [Function: Connection],
  Iris: [Function: Iris],
  Iterator: [Function: Iterator],
  IRISList: [Function: IRISList]
}
.....
>     var connection = irisnative.createConnection({
...     host: ip,
...     port: port,
...     ns: namespace,
...     user: username,
...     pwd: password
...     })
Uncaught Error: 8-bit servers are not supported [ERROR_8BIT_SERVER]
>

 

1
0 170
Announcement Rob Tweed · Apr 5, 2024

Hot on the heels of our announcement last week about our ultra-high-performance mg-dbx-napi JavaScript interface for IRIS, we are now pleased to announce a significant new technology - mg_web - which not only represents a new paradigm for JavaScript Web Frameworks, but also delivers significantly higher performance than even the fastest of the established Node.js Web Frameworks, whilst leveraging all the benefits of the big-three industry-standard Web Servers.

1
3 324
Announcement Rob Tweed · Sep 28, 2022

I'd like to announce the release of something really rather interesting - revolutionary in fact.  That may sound like hyperbole, but I don't think you'll have seen anything quite like this, or even thought it possible!

We've pushed out a new JavaScript/Node.js module named glsdb which you can read all about here in detail:

https://github.com/robtweed/glsdb

However, for the purposes of this announcement here, I just want to focus on one part of glsdb: its APIs that abstract IRIS (or Cache) Classes as equivalent JavaScript Objects.

8
1 423
Announcement Rob Tweed · Mar 26, 2024

You may have heard about our mg-dbx-napi interface for IRIS which provides insanely fast access from Node.js.  If you've been following recent developments in the server-side JavaScript world, you'll be excited to know that mg-dbx-napi also works with Bun.js, the latter proving to be significantly faster than Node.js for many/most purposes.

Of course, if you're a Node.js user, you'll probably wonder how mg-dbx-napi compares with the Native API for Node.js that is included with IRIS.

With all that in mind, we've created a Github repository: mg-showcase

8
2 290
Article Lily Taub · Mar 19, 2019 9m read

Intro

Most server-client communication on the web is based on a request and response structure. The client sends a request to the server and the server responds to this request. The WebSocket protocol provides a two-way channel of communication between a server and client, allowing servers to send messages to clients without first receiving a request. For more information on the WebSocket protocol and its implementation in InterSystems IRIS, see the links below.

This tutorial is an update of "Asynchronous Websockets -- a quick tutorial" for Caché 2016.2+ and InterSystems IRIS 2018.1+.

Asynchronous vs Synchronous Operation

In InterSystems IRIS, a WebSocket connection can be implemented synchronously or asynchronously. How the WebSocket connection between client and server operates is determined by the “SharedConnection” property of the %CSP.WebSocket class.

  • SharedConnection=1 : Asynchronous operation

  • SharedConnection=0: Synchronous operation

A WebSocket connection between a client and a server hosted on an InterSystems IRIS instance includes a connection between the IRIS instance and the Web Gateway. In synchronous WebSocket operation, the connection uses a private channel. In asynchronous WebSocket operation, a group of WebSocket clients share a pool of connections between the IRIS instance and the Web Gateway. The advantage of an asynchronous implementation of WebSockets stands out when one has many clients connecting to the same server, as this implementation does not require that each client be handled by an exclusive connection between the Web Gateway and IRIS instance.

In this tutorial we will be implementing WebSockets asynchronously. Thus, all open chat windows share a pool of connections between the Web Gateway and the IRIS instance that hosts the WebSocket server class.

Chat Application Overview

The “hello world” of WebSockets is a chat application in which a user can send messages that are broadcast to all users logged into the application. In this tutorial, the components of the chat application include:

  • Server: implemented in a class that extends %CSP.WebSocket

  • Client: implemented by a CSP page

The implementation of this chat application will achieve the following:

  • Users can broadcast messages to all open chat windows

  • Online users will appear in the “Online Users” list of all open chat windows

  • Users can change their username by composing a message starting with the “alias” keyword and this message will not be broadcast but will update the “Online Users” list

  • When users close their chat window they will be removed from the “Online Users” list

For the chat application source code, please visit this GitHub repository.

The Client

The client side of our chat application is implemented by a CSP page containing the styling for the chat window, the declaration of the WebSocket connection, WebSocket events and methods that handle communication to and from the server, and helper functions that package messages sent to the server and process incoming messages.

First, we’ll look at how the application initiates the WebSocket connection using a Javascript WebSocket library.

    ws = new WebSocket(((window.location.protocol === "https:")? "wss:":"ws:")
                    + "//"+ window.location.host + "/csp/user/Chat.Server.cls");

new creates a new instance of the WebSocket class. This opens a WebSocket connection to the server using the "wss” (indicates the use of TLS for the WebSocket communication channel) or “ws” protocol. The server is specified by the web server port number and host name of the instance that defines the Chat.Server class (this information is contained in the window.location.host variable). The name of our server class (Chat.Server.cls) is included in the WebSocket opening URI as a GET request for the resource on the server.

The ws.onopen event fires when the WebSocket connection is successfully established, transitioning from a connecting to a open state.

    ws.onopen = function(event){
        document.getElementById("headline").innerHTML = "CHAT - CONNECTED";
    };

This event updates the header of the chat window to indicate that the client and server are connected.

Sending Messages

The action of a user sending a message triggers the send function. This function serves as a wrapper around the ws.send method, which contains the mechanics for sending the client message to the server over the WebSocket connection.

function send() {
	var line=$("#inputline").val();
	if (line.substr(0,5)=="alias"){
	    alias=line.split(" ")[1];
		if (alias==""){
		    alias="default";
		}
		var data = {}
		data.User = alias
		ws.send(JSON.stringify(data));
        } else {
	    var msg=btoa(line);
	    var data={};
	    data.Message=msg;
	    data.Author=alias;
	    if (ws && msg!="") {
		    ws.send(JSON.stringify(data));
	    }
	}
	$("#inputline").val("");
}

send packages the information to be sent to the server in a JSON object, defining key/value pairs according to the type of information being sent (alias update or general message). btoa translates the contents of a general message into a base-64 encoded ASCII string.

Receiving Messages

When the client receives a message from the server, the ws.onmessage event is triggered.

ws.onmessage = function(event) {
	var d=JSON.parse(event.data);
	if (d.Type=="Chat") {
	    $("#chat").append(wrapmessage(d));
            $("#chatdiv").animate({ scrollTop: $('#chatdiv').prop("scrollHeight")}, 1000);
	} else if(d.Type=="userlist") {
		var ul = document.getElementById("userlist");
		while(ul.firstChild){ul.removeChild(ul.firstChild)};
		$("#userlist").append(wrapuser(d.Users));
	} else if(d.Type=="Status"){
		document.getElementById("headline").innerHTML = "CHAT - connected - "+d.WSID;
	}
};

Depending on the type of message the client receives (“Chat”, “userlist”, or “status”), the onmessage event calls wrapmessage or wrapuser to populate the appropriate sections of the chat window with the incoming data. If the incoming message is a status update the status header of the chat window is updated with the WebSocket ID, which identifies the bidirectional WebSocket connection associated with the chat window.

Additional Client Components

An error in the communication between the client and the server triggers the WebSocket onerror method, which issues an alert that notifies us of the error and updates the page's status header.

ws.onerror = function(event) {
	document.GetElementById("headline").innerHTML = "CHAT - error";
	alert("Received error"); 
};

The onclose method is triggered when the WebSocket connection between the client and server is closed and updates the status header.

ws.onclose = function(event) {
	ws = null;
	document.getElementById("headline").innerHTML = "CHAT - disconnected";
}

The Server

The server side of the chat application is implemented by the Chat.Server class, which extends %CSP.WebSocket. Our server class inherits various properties and methods from %CSP.WebSocket, a few of which I’ll discuss below. Chat.Server also implements custom methods to process messages from and broadcast messages to the client(s).

Before Starting the Server

OnPreServer() is executed before the WebSocket server is created and is inherited from the %CSP.WebSocket class.

Method OnPreServer() As %Status
{
    set ..SharedConnection=1
    if (..WebSocketID '= ""){ 
        set ^Chat.WebSocketConnections(..WebSocketID)=""
    } else {
        set ^Chat.Errors($INCREMENT(^Chat.Errors),"no websocketid defined")=$HOROLOG 
    }
    Quit $$$OK
}

This method sets the SharedConnection class parameter to 1, indicating that our WebSocket connection will be asynchronous and supported by multiple processes that define connections between the InterSystems IRIS instance and the Web Gateway. The SharedConnection parameter can only be changed in OnPreServer(). OnPreServer() also stores the WebSocket ID associated with the client in the ^Chat.WebSocketConnections global.

The Server Method

The main body of logic executed by the server is contained in the Server() method.

Method Server() As %Status
{
    do ..StatusUpdate(..WebSocketID)
    for {		
        set data=..Read(.size,.sc,1) 
        if ($$$ISERR(sc)){
            if ($$$GETERRORCODE(sc)=$$$CSPWebSocketTimeout) {
                //$$$DEBUG("no data")
      	    }
            if ($$$GETERRORCODE(sc)=$$$CSPWebSocketClosed){
                kill ^Chat.WebSocketConnections(..WebSocketID)
                do ..RemoveUser($g(^Chat.Users(..WebSocketID)))	
                kill ^Chat.Users(..WebSocketID)
                quit  // Client closed WebSocket
            }
        } else{
            if data["User"{
                do ..AddUser(data,..WebSocketID)
            } else {
                set mid=$INCREMENT(^Chat.Messages)
                set ^Chat.Messages(mid)=data
                do ..ProcessMessage(mid)
            }
        }
    }
    Quit $$$OK
}

This method reads incoming messages from the client (using the Read method of the %CSP.WebSockets class), adds the received JSON objects to the ^Chat.Messages global, and calls ProcessMessage() to forward the message to all other connected chat clients. When a user closes their chat window (thus terminating the WebSocket connection to the server), the Server() method’s call to Read returns an error code that evaluates to the macro $$$CSPWebSocketClosed and the method proceeds to handle the closure accordingly.

Processing and Distributing Messages

ProcessMessage() adds metadata to the incoming chat message and calls SendData(), passing the message as a parameter.

ClassMethod ProcessMessage(mid As %String)
{
    set msg = ##class(%DynamicObject).%FromJSON($GET(^Chat.Messages(mid)))
    set msg.Type="Chat"
    set msg.Sent=$ZDATETIME($HOROLOG,3)
    do ..SendData(msg)
}

ProcessMessage() retrieves the JSON formatted message from the ^Chat.Messages global and converts it to an InterSystems IRIS object using the %DynamicObject class' %FromJSON method. This allows us to easily edit the data before we forward the message to all connected chat clients. We add a Type attribute with the value “Chat,” which the client uses to determine how to deal with the incoming message. SendData() sends out the message to all the other connected chat clients.

ClassMethod SendData(data As %DynamicObject)
{
    set c = ""
    for {
        set c = $order(^Chat.WebSocketConnections(c))
        if c="" Quit
        set ws = ..%New()
        set sc = ws.OpenServer(c)
        if $$$ISERR(sc) { do ..HandleError(c,"open") } 
        set sc = ws.Write(data.%ToJSON())
        if $$$ISERR(sc) { do ..HandleError(c,"write") }
    }
}

SendData() converts the InterSystems IRIS object back into a JSON string (data.%ToJSON()) and pushes the message to all the chat clients. SendData() gets the WebSocket ID associated with each client-server connection from the ^Chat.WebSocketConnections global and uses the ID to open a WebSocket connection via the OpenServer method of the %CSP.WebSocket class. We can use the OpenServer method to do this because our WebSocket connections are asynchronous – we pull from the existing pool of IRIS-Web Gateway processes and assign one the WebSocket ID that identifies the server’s connection to a specific chat client. Finally, the Write()%CSP.WebSocket method pushes the JSON string representation of the message to the client.

Conclusion

This chat application demonstrates how to establish WebSocket connections between a client and server hosted by InterSystems IRIS. For continue reading on the protocol and its implementation in InterSystems IRIS, take a look at the links in the introduction.

7
3 6042
Question Dmitrii Baranov · Feb 26, 2024

IRIS is known to have a built-in Python bridge and even allows you to write Python server code but what about JavaScript? Let's say I need a JavaScript expression interpreter. What would you recommend as the most effective way to get one? It is highly desirable that the solution does not require administrator privileges and uses in-process communication (I mean not http and not unix-specific interprocess-communication via command line)

2
0 214