#ObjectScript

0 Followers · 1.5K 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 Nikolay Solovyev · Jul 29 3m read

Sending emails is a common requirement in integration scenarios — whether for client reminders, automatic reports, or transaction confirmations. Static messages quickly become hard to maintain and personalize. This is where the templated_email module comes in, combining InterSystems IRIS Interoperability with the power of Jinja2 templates.

Why Jinja2 for Emails

Jinja2 is a popular templating engine from the Python ecosystem that enables fully dynamic content generation. It supports:

0
0 0
Article Guillaume Rongier · Jul 28 3m read

This will be a short article about Python dunder methods, also known as magic methods.

What are Dunder Methods?

Dunder methods are special methods in Python that start and end with double underscores (__). They allow you to define the behavior of your objects for built-in operations, such as addition, subtraction, string representation, and more.

Some common dunder methods include:

0
0 0
Article Vachan C Rannore · Jul 24 1m read

Are you curious about how to run Python scripts directly in your InterSystems IRIS or Caché terminal? 🤔 Good news it's easy! 😆 IRIS supports Embedded Python, allowing you to use Python interactively within its terminal environment. 

How to access the Python Shell?

To launch the Python shell from the IRIS terminal, simply run the following command:

do##class(%SYS.Python).Shell()

This opens an interactive Python shell inside the IRIS terminal. From here, you can write and run Python code just as you would in a normal Python environment.

Exiting the Shell:

>>> quit()

0
0 0
Article Guillaume Rongier · Jul 24 5m read

Modules what a topic! We don't have this notion in ObjectScript, but it's a fundamental concept in Python. Let's discover it together.

What is a Module?

I see modules as an intermediate layer between classes and packages. Let see it by example.

A bad example :

# MyClass.py
class MyClass:
    def my_method(self):
        print("Hello from MyClass!")

When you try to use this class in another script, you would do:

# class_usage.py
from MyClass import MyClass # weird, right?

my_instance = MyClass()
my_instance.my_method()

Why this is a bad example?

0
0 0
Question Ronaldo Nascimento · Jul 22

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.

0
0 0
InterSystems Official Raj Singh · Jul 21

InterSystems is pleased to announce that version 3.0.5 of the VS Code - ObjectScript extension has been released. This release includes many bug fixes, as well as changes to the telemetry data we collect. Collecting more product usage data helps InterSystems identify and prioritize fixes and enhancements that will have the most positive impact for you, our users. Personally identifiable information (PII) will never be collected, and telemetry can be disabled using the telemetry.telemetryLevel setting. The full list of data points that are collected can be found here. Thank you for using our

0
0 0
Question Ronaldo Nascimento · Jul 18

I am trying to create users who only have `%SQL` Role for the INSTANCE. But I am unable to find any documentation on the `Security.Users` class.

See:

// Instantiate the Security.Users objectSet userObj = ##class(Security.Users).%New()// Set the username and passwordSet userObj.Name = userNameSet userObj.FullName = userFullNameSet userObj.Namespace = "USER"Set userObj.Roles = "%SQL"
   Set sc = userObj.ChangePassword(passwd)// Save the user to the databaseSet ss = userObj.%Save()
0
0 0
Question Adel Elsayed · Jul 21, 2021

in order to do analysis on huge data volumes, it is better to take you data to a separate machine for analysis away from the operational machine, so trying to write huge globals or tables into files as is would take a huge space, what could be a solution or best practice ?..in python for instance, there is the pickling option (serializes data to byte string and saves it to a file) to save space, what could be best in object script ?

11
0 1581
Article Guillaume Rongier · Jul 17 5m read

This will be an introduction to Python programming in the context of IRIS.

Before anything I will cover an important topic: How python works, this will help you understand some issues and limitations you may encounter when working with Python in IRIS.

All the articles and examples can be found in this git repository: iris-python-article

How Python works

Interpreted Language

Python is an interpreted language, which means that the code is executed line by line at runtime even when you import a script.

What does this mean ? Let's take a look at the following code:

0
0 0
Article David Hockenbroch · Jul 10 16m read

Dear community, I have a confession to make. I have not gotten over Zen yet. Alas, all good things must come to an EOF, so I am currently learning about Angular. I am working on proving to myself that with the right back end and Angular components, I can deliver to myself and my team a very Zen-like experience in this environment. Since this is my first attempt, here is a fair warning: I will be providing some rather large code samples before discussing them. Please warm up your mouse and hand for extensive upcoming scrolling! Also, a note on the code snippets: many of them are labeled

0
0 0
Question Scott Roth · Jul 14

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"

0
0 0
Discussion Vadim Aniskin · Aug 15, 2023

Hi Developers!

There is a free ObjectScriptQuality tool for ObjectScript developers who upload solutions on GitHub. This tool helps developers validate ObjectScript code using a variety of rules, based on common code errors.

There are currently 16 rules in this tool, but there are definitely many more rules to consider when testing ObjectScript code.

Could you suggest any other rules to add to this tool?

12
0 412
Question steven Henry · Jul 10

Hello my friends,

I have a problem with Objectscript, why the value of address become like this ?

everything works fine except the Address,

this is my code, do I need something to make this into real address ? should I put something in my code ? 

 set paper=obj.PAADMPAPMIDR.PAPMIPAPERDR

            if '$isobject(paper) continue

            set Address=paper.PAPERStName

thank you for your help

Best Regards,

Steven Henry

0
0 0
Article David Hockenbroch · Sep 11, 2024 9m read

Do not let the title of this article confuse you; we are not planning to take the InterSystems staff out to a fine Italian restaurant. Instead, this article will cover the principles of working with date and time data types in IRIS. When we use these data types, we should be aware of three different conversion issues:

  1. Converting between internal and ODBC formats.
  2. Converting between local time, UTC, and Posix time.
  3. Converting to and from various date display formats.
0
0 0
Article Henry Ames · Jun 18 2m read

I am writing this post primarily to gather an informal consensus on how developers are using Python in conjunction with IRIS, so please respond to the poll at the end of this article! In the body of the article, I'll give some background on each choice provided, as well as the advantages for each, but feel free to skim over it and just respond to the poll.

0
0 0
Discussion Evgeny Shvarov · Jun 21

Hi fellow developers!

Curious if you guys use CreatedAt and LastUpdated properties in your classes?

Created to stamp when the record was created and LastUpdated when it was last updated. Where it can be useful - almost everywhere )) I find it convenient in records sorting (e.g. by creation or last update), in sync (with other systems), and so on, for better analytics.

Do you use it all the time for all the classes?

If don't, why not? What do you use instead?

What property type do you use - %TimeStamp? %DateTime?

0
0 0
Question Shashvati Dash · Jul 1

The below code is not working. its unable retrieve Record count and merge files

Class Util

{

ClassMethod zPyRecordCount(inputfile) As %Integer [ Language = python ]

{

    import pandas as pd

    import iris

    import io

    try:

        df = pd.read_csv(inputfile, sep='|')

        recordcount=len(df.index)

        sys.stdout.write(len(df.index))

        return recordcount

    except Exception as e:

        return 0

}

ClassMethod zPymergefiles(file1, file2, outputfilename) As %Boolean [ Language = python ]

{

    import pandas as pd

    import iris

    import io

    try:

0
0 0
Question Evgeny Shvarov · Jun 29

Hi noble devs!

Just building a simple frontend->JSON->IRIS backend story, and figured that IRIS while importing via %JSON.Adaptor wants JSON fields to match property names, meaning even should match the case. Like:

{ name: "John", 

surname: "Doe"}

will have issues while saving the dynamic object to a class Sample.Person with:

Class Sample.Person Extends (%Persistent, %JSON.Adaptor)

{

Property Name: %Sting;Property Surname: %String;
}

As soon as the case is not the same... 

0
0 0
Article Marco Bahamondes · Jun 24 3m read

Introduction

InterSystems IRIS allows you to build REST APIs using ObjectScript classes and the %CSP.REST framework. This enables the development of modern services to expose data for web apps, mobile apps, or system integrations.

In this article, you'll learn how to create a basic REST API in InterSystems IRIS, including:

  • A persistent data class
  • A REST class with GET and POST methods
  • A web application to expose the API
  • A full demonstration using Docker

Step 1: Create the data class Demo.Producto

0
0 0
Question Kurro Lopez · Jun 23

Hi all,

We're developing a medical appointment app that connects doctors' schedules to an appointment provider.

The provider is returning us the appointment in the following format:

Thu Jul 03 08:20:00 CEST 2025

It means, 03 july 2025 at 08:20:00 Central European Summer Time (UTC+2)

But we need the following format:

2025-07-03 08:20:00+02:00

Is there any option to convert zone time code (CEST) to a UTC+x ?

How to convert zone time code (CEST, CET, ET, EDT, etc..) in its zone time in UTC (UTC+2, UTC+1, UTC-5, etc..) ?

Best regards

0
0 0
Question Vladimir Vodicka · Jun 20

Hello,

I have a problem generating QR code in Caché now.

After executing the code

set Status=##Class(%SYS.QRCode).GenerateImage(P0,,.DataURI)

(variable P0 contains data for QR code)

an error is displayed now:

"<NOTOPEN>zGenerate+27^%SYS.QRCode.1",,,,,,,,

("$^zGenerate+27^%SYS.QRCode.1 +1","$^zGenerateImage+4^%SYS.QRCode.1 +1"

This error occurs only on two servers, on the others the code works fine.

When calling the method, I do not specify any external file that should be opened.

Thank you for the answers.

0
0 0
Question Alexey Maslov · Jun 10

Having been inspired with Shared code execution speed question/discussion, I dare to ask another one which is annoying me and my colleagues for several weeks.

We have a routine called Lib that comprises 200 $$-functions of 1500 code lines total. It was noticed that after calling _any_ function of another rather big routine (1900 functions, 32000 lines) the next call of $$someFunction^Lib(x) is getting 10-20% slower than previous call of the same function. This effect doesn't depend on: 

0
0 0
Article Shuheng Liu · May 16 9m read

1. A Motivating Example

Embedded Python has been around for a while. You probably followed the tutorials and learned about it. However, if you've tried to combine Python and ObjectScript in real development work, you probably ran into situations where you get an error message like this:

USER>Do##class(MyClass).SomeMethod()

ERROR #5002: ObjectScript error: <PYTHON EXCEPTION> *<class 'ZeroDivisionError'>: division by zero
0
0 0
Discussion Harshitha · May 30

Hey everyone,

I'm diving deeper into Caché ObjectScript and would love to open a discussion around the most useful tips, tricks, and best practices you’ve learned or discovered while working with it.

Whether you're an experienced developer or just getting started, ObjectScript has its own set of quirks and powerful features—some well-documented, others hidden gems. I’m looking to compile a helpful set of ideas from the community.

Some areas I’m especially interested in:

0
0 0