#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 Harry Tong · Jun 6 2m read

If you're migrating from Oracle to InterSystems IRIS—like many of my customers—you may run into Oracle-specific SQL patterns that need translation.

Take this example:

SELECT (TO_DATE('2023-05-12','YYYY-MM-DD') - LEVEL + 1) AS gap_date
FROM dual
CONNECT BY LEVEL <= (TO_DATE('2023-05-12','YYYY-MM-DD') - TO_DATE('2023-05-02','YYYY-MM-DD') + 1);

In Oracle:

0
0 0
Question Scott Roth · Jun 11

I am having a hard time trying to figure out the following...

Within a DTC, I was able to take the a EnsLib.HL7.Message source and using

set a= $System.Encryption.Base64Encode(source.RawContent)
set encodedMessage=$Get(a)

to take the HL7 message encode it and add it to the Data Class as a string to be sent to an Operation to be sent out as a SOAP Request. 

However to make it more universal I tried doing this within a copy of EnsLib.HL7.SOAPOperation

0
0 0
Question Dmitry Maslennikov · Mar 30, 2024

During the realization of some required functionality, I discovered that I need to use Deflate compression, and found, that IRIS does not offer any options, $system.Util.Compress, works one way open (GZIP/COMPRESS) totally different, even for the same algorithms, I see that what I would expect as a result for Deflate somewhere there, but Compress returns something more. Is there any way to get a correct result using just ObjectScript without a need to use external tools? Was it really so difficult to have Deflate implemented in the first place?

0
0 442
Question Fabio Care · May 27

I am testing vectorsearch, while doing so I am trying to paginate my resultset for a "next page" function to give me the first, second, third 15 entries within a table. 

For this I have two embedding classes. One with a HNSW Index (vectornomicembedtextlatest) , and one without (vectornomicembedtexttest).

Calling SELECT ID,PRIMKEY FROM SQLUser.vectornomicembedtexttest LIMIT 5 OFFSET 1 works fine with the first entry having the rowID of 486448. (I deleted old entries in the beginning and reused the table)

0
0 0
Question Ashok Kumar T · May 22

Hello Community,

When I run the following code with x undefined in terminal, it throws a syntax error and returns control to the program stack. After issuing a GO command, execution continues, and setting the global variable ^zz1.

code 1:

test.mac
if$Data(@x@(a,b,c)) {
    set^zz1=1212
}
write !,1212,!
////orif$Data(@x@(a,b,c)) set^zz1=1212write !,1212,!

 if I assign the result of $D(@x@(a,b,c)) to a local variable like d using set d=$D(@x@(a,b,c)), and then use if d { ... }, the code fails(global is not set) working as expected.

Code 2

0
0 0
Question Laura Blázquez García · May 16

I'm creating a Business Process that:

  1. Transforms one object into another using DTL
  2. Sends this object to an operation
  3. Transform the object obtained in first point into another one using DTL
  4. Sends the second object to an operation

The Business Process is created with BPL, and objects are stored in BP context. When I execute this Process, in the 3rd point the object obtained in first transformation doesn't exist. It's empty.

I have tried to make transformation before making CALL's, I mean:

0
0 0
Question Ashok Kumar T · May 16

Hello Community,

Is it possible to retrieve/find all the names of subroutines, procedures, or functions from a deployed routine?. in the routine below, how can I extract names like x2 and execsql? I’ve just tried using openId on %RoutineMgr  but it didn’t help.

xdeploy.mac
xdeploy
 quit
x2 ; test1write123q
execsql(sql) ; test2Set tResult = ##Class(%SQL.Statement).%ExecDirect(,sql)
 Return tResult

Thanks

0
0 0
Question Ashok Kumar T · May 8

Hello Community,

I executed the below query in the %ZLANGC00.mac routine. It returns results when using dynamic SQL, but not with embedded SQL(returns 0). 

 &SQL(SELECTcount(*) INTO :Cnt FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'")
 Write "SQLTablecount : "_Cnt,!
 Set tResultSet = ##class(%SQL.Statement).%ExecDirect(,"SELECTcount(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'")
 Do tResultSet.%Display()

Thanks!

0
0 0
Question Julius Kavay · Apr 29

According to documentation, quotation: "$THIS contains the current class context.The class context for an instance method is the current object reference (OREF).The class context for a class method is the current classname as a string value." As my example below shows, either the documentation or the implementation (or both) is wrong, I always call a class method (Value) and expected the class name as the return value but got either the class name or an OREF. Moreover, if I repeat the call, I get another values. But why?Does anyone have a clear explanation (for an aging brain) or have I

0
0 0
Question Scott Roth · May 6

I am trying to replicate a REST call that I am able to make via a Postman call within a EnsLib.REST.GenericOperation.

It's been a while since I have messed around with trying to make external REST calls. When I execute my REST call, tSC is coming back with an error and I am trying to pinpoint why. I tried turning on ISCLOG = 5 but when calling the REST Operation from the Testing tool it is not logging anything to the ISC log.

0
0 0
Article Padmaja Konduru · May 6 3m read

It helps to remove special characters, such as non-utf-8 characters either control characters or unicode characters from text that is not printable or can't be parsed by downstream systems.

There is also $C(32) in this condition; sometimes NBSP appears in the text and it will not be recognized by TIE, but downstream it displays as "?".

In order to avoid the NBSP issue, the if condition is replaced with a space in order to prevent the error.

Unicode characters only Remove:

0
0 0
Question Evgeny Shvarov · Apr 7

Hi devs!

Suppose I have an instance of a persistent class:

Set person = ##class(dc.Sample.Person).%OpenId(1)

Class is an ancestor of %JSON.Adapter.

How can I convert it to dynamic object with the properties that person.%JSONExport() provides?

{"Name":"Elon Mask","Title":"Associate Accountant","Company":"InterSystems","Phone":"799-933-5569","DOB":"1926-12-11"}

Couldn't find a right method. 

0
0 0
Article David Hockenbroch · Apr 22 7m read

The Good Old Days

The %Library.DynamicObject class has been in IRIS since before it became IRIS. If you have been using it since the Cache days, you may want to brush up on some of its changes.

In Cache 2018, the %Get method only had one argument. It was the key to retrieving from the JSON, meaning that if your JSON object called myObj, it would look like the following:

0
0 0
Article Jean Millette · Apr 23 7m read

I have a new project to store information from REST responses into an IRIS database. I’ll need to sync information from at least two dozen separate REST endpoints, which means creating nearly that many ObjectScript classes to store the results from those endpoints.

Could I use ChatGPT to get a headstart on creating these classes? The answer is “Yes”, which is great since this is my first attempt at using generative AI for something useful. Generating pictures of giraffes eating soup was getting kind of old….

Here’s what I did:

0
0 0
Question Scott Roth · Apr 22

I was wondering if someone could help me. In the past I have been able to call external Stored Procedures through a SQL Outbound Connection and have them return me the EnsLib.SQL.Snapshot to use within a BPL to extract data.

But this time instead of using a SQL Outbound BO to make the Stored Procedure call, I decided to create a Linked Stored Procedure through the %JDBC_Server to point to the Stored Procedure out on MS SQL.

However, I am struggling to get the code just right to return the Column value from the Linked Stored Procedure.

0
0 0
Question Patrik Spisak · Apr 19

After upgrading from 2024 to 2025 Im not able to compile any class.

I was using ZPM and git-source-control.

Now Im getting 

Compilation started on 04/19/202520:53:00 with qualifiers 'cuk /checkuptodate=expandedonly'

ERROR #5002: ObjectScript error: <CLASS DOES NOT EXIST>OnAfterSave+4^SourceControl.Git.Extension.1 *SourceControl.Git.Utils
Detected 1 errors during compilation in 0.209s. class '%Studio.SourceControl.Interface', method 'OnBeforeTimestamp': <CLASS DOES NOT EXIST> 150 

I disabled SourceControl in Management portal and nothing happen.

0
0 0
Question Raj Singh · Jun 9, 2020

Say I have an ObjectScript object called Book. It has 2 properties title and author. It extends JSON.%Adaptor, so I can call book.%JSONExport() and get this output:

{ "title": "For Whom the Bell Tolls", "author": "Hemmingway" }

In my web service I want to have a search function that returns an array of Books along with the total number of responses, like this: 

{
    "results": 3,
    "items": [
        { "title": "For Whom the Bell Tolls", "author": "Hemmingway" },
        { "title": "The Invisible Man", "author": "Ellison" }, 
        { "title": "Tender is the Night", "author": "Fitzgerald" }
    ]

}
18
2 2048