#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.

Question Colin Brough · May 9, 2024

We have a custom business service that is triggered by a scheduled task. The service queries a table, iterates over the result set and sends a message on to a business process for each result. Happy path functionality is all fine.

However, when there is an error detected in the business service code, neither throwing an exception nor returning an error %Status behaves as we'd expect.

0
0 141
Question Florian Hansmann · Feb 27, 2020

Hello Community,

My Intersystems Caché Version: 1.2014 (Can't update now.)

I have the following issue:

I have for example an articlenumber with 15049950, which is numeric. But sometimes it can also be an alphanumeric string like PK15049950.

How can i set numbers always to string in Json Stream with quotes like "15049950".

Code Example:

set object = ##class(%ZEN.proxyObject).%New()

set articlenumber = "15049950"

set object.articlenumber = articlenumber

set x = ##class(%ZEN.Auxiliary.jsonArrayProvider).%WriteJSONStreamFromObject(.json,object)

Will output:

{

 "articlenumber": 15049950

}

but I want always:

{

5
0 416
Article Rob Tweed · Apr 30, 2024 3m read

A few weeks ago I posted an announcement about a JavaScript-based interface for our mg_web WebServer interfacing addon module.  mg_web isn't just restricted to use by JavaScript developers though.  Many readers will be ObjectScript developers who are more used to using CSP as their web gateway.  Some may even have much older legacy WebLink-based applications (and be wondering how to support them given that IRIS does not support WebLink).

This article aims to provide some more information on mg_web and to explain why it's worth a look for ObjectScript developers.

0
0 306
Article Robert Cemper · Apr 26, 2024 3m read

Technical surprises using VECTORs
>>> UPDATED

Building my tech. example provided me with a bunch of findings htt I want to share.
The first vectors I touched appeared with text analysis and more than 200  dimensions.
I have to confess that I feel well with Einstein's 4 dimensional world.
7 to 15 dimensions populating the String Theory are somewhat across the border.
But 200 and more is definitely far beyond my mathematical horizon.

0
0 295
Question Pravin Barton · Apr 25, 2024

Is there a way to exclude specific members from a class when exporting to an XML or UDL file? Bonus question: is there a way to import from that file without overwriting those members that were excluded?

The use case is to export an interoperability production class without the ProductionDefinition XDATA. We plan to source control the production items through the Ensemble Deployment Manager, but we still need to export any custom code in the class definition itself.

1
0 163
Question Yuhong Snyder · Apr 25, 2024

We are using the IRIS cloud. and I am working on a DTL .

so the source side timestamp is  local time for example 20240110134740,  I know it is a local time. so the requirement is I need to append the UTC at the end, like -0400 or -0500 depending on if it is daylight saving time.  

so is there function to return if current day is at daylight saving time, so I can decide if I need to append the -400 or -500? or a function to return the current UTC by location? 

0
0 160
Article David Hockenbroch · Apr 25, 2024 3m read

I came up with a challenge for myself to come up with a way to make a variable watch itself for a certain value and do something when it hits that value without having to check it every time something touches it. Basically, a way to say "if at any point during the execution of this code, if x = 0 (or whatever the condition is) do this thing." The class I ended up with watches a %Status:

0
0 287
Question Michael Davidovich · Apr 24, 2024

Hello, I'm curious to see how other people deal with this: we have a text file that was created on someone's Windows machine and it was copied and pasted into a text file on someone's Mac machine.  After some examination we realized that the line feeds were originally CRLF (for Windows) and when copied and pasted they were changed to LF (Mac).  The diff program we used didn't pick up on this and the program we wrote to read the file was getting each line of the CRLF file and treating the whole file as one line for the LF file. 

0
0 228
Article Robbie Luman · Jan 12, 2024 7m read

With the advent of Embedded Python, a myriad of use cases are now possible from within IRIS directly using Python libraries for more complex operations. One such operation is the use of natural language processing tools such as textual similarity comparison.

Setting up Embedded Python to Use the Sentence Transformers Library

3
3 582
Article Eyal Levin · Apr 8, 2024 1m read

Hi,

I was struggling with a procedure that was meant to receive a string and use it as a filter, I've found that since I want the procedure to do some data transformation and return a dataset, I needed to use objectScript language.

I've created the procedure using the SQL GUI in the portal, and everything works fine when calling the procedure from the SQL GUI but not through a JDBC connection here is the call "call spPatientOS('2024-04-07T12:35:32Z')"

0
0 273
Question Michael Lundberg · Apr 15, 2024

Hello!

I wonder if anyone has a smart idea to extract an XML fragment inside a text document (incoming from a stream)?

The XML fragment is surrounded by plain text.

Example:

text...........
text...........
<?xml version="1.0" encoding="UTF-8 ?>
<Start>
...etc
</Start>
text...........
text...........

The XML is not represented by any class or object in the Namespace.

The XML can look different from time to time

Appreciated if anyone knows how to use Objectscript to extract the XML content.

Regards Michael

0
0 313
Question Pietro Di Leo · Apr 17, 2024

Hello everybody, 

I've been experimenting with Embedded Python and have been following the steps outlined in this documentation: https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cl…

I'm trying to convert a python dictionary into an objectscript array but there is an issue with the 'arrayref' function, that is not working as in the linked example.

This is a snapshoot of my IRIS terminal: 

0
0 199
Article Evgeny Shvarov · Aug 9, 2021 1m read

Hi developers!

Just want to share an old but always relevant best practice on namespaces changing @Dmitry Maslennikov shared with me (again).

Consider method:

classmethod DoSomethingInSYS() as %Status

{

set sc=$$$OK

set ns=$namespace

zn "%SYS"

// try-catch in case there will be an error

try {

// do something, e.g. config change

}

catch {}

 zn ns    ; returning back to the namespace we came in the routine

return sc

}

And with new $namespace the method could be rewritten as:

4
0 739
Question Thomas Haig · Apr 10, 2024

Have successfully installed the Intersystems ObjectScript Extension Pack (version last updated 2024-03-26) in VS Code version 1.88 and when creating a new Class (in a New File of type ObjectScript-class) I am presented only with the following snippets:


When watching the Intersystems training videos (I am fairly new to IS) I notice there are far more options provided. For example from the video "Creating a Custom HL7 V2 Search Table" the following snippets are presented:

0
0 151
Article Davi Massaru Teixeira Muta · Apr 10, 2024 3m read

If you have system tables implementing the "VERSIONPROPERTY" functionality, you may encounter error 5800. This article explains how this error occurs and provides solutions to resolve the issue.

When version checking is implemented, the property specified by VERSIONPROPERTY is automatically incremented each time an instance of the class is updated (either by objects or SQL).

For example:

0
0 239
Question Colin Brough · Apr 8, 2024

We are writing a custom Business Operation to interact with a downstream SOAP web-service. Classes for the SOAP operation were originally generated using the SOAP Wizard, then modified. This is functioning OK, but we'd now like to set the ReplyCodeActions setting on the operation and are struggling to make it visible via the management portal. How can we achieve this?

The classes are structured like this:

0
0 173
Question Joe Jones · Mar 17, 2023

Hi Community,

I am trying to read a JSON file and convert into HL7 message.Please find the example below

Set Jsonobj={"Doctype":"ADT^A01","PatientId":"123","PatientName":"Alex"}

Set Dynjsonobj=##class(%Library.DynamicObject).%FromJSON(Jsonobj)

Error :<THROW>%FromJSON+37^%Library.DynamicAbstractObject.1 *%Exception.General READ error while reading input stream 10 Line 1 Offset 0

I am getting this error while reading the file,Can you please tell me where i am doing wrong in converting the file?

Joe

8
0 1107
Article Ewan Whyte · Mar 19, 2024 3m read

Introduction

There is a Link Procedure Wizard option within the Management Portal (System > SQL >Wizards > Link Procedure) which I had reliability issues with so I decided to use this solution instead.

Problem

You need to query an external SQL database to use the response within a namespace. This guide is assuming that you already have a working stored procedure in SSMS although you could instead use a SQL block within the operation. Stored procedures in SSMS are preferred to maintain integrity, Embedded SQL can get very confusing if you have a complicated SQL statement.

0
0 405
Question Kim Trieu · Mar 26, 2024

Using VECTOR_COSINE() in SQL query to perform a text similarity search on existing embeddings in a %VECTOR column.

Code is below.

Commented out sql query returns this error: SQLCODE: -29  Field 'NEW_EMBEDDING_STR' not found in the applicable tables^ SELECT TOP ? maxID , activity , outcome FROMMain .AITest ORDER BY VECTOR_COSINE ( new_embedding_str ,

Sql query as written returns ERROR #5002: ObjectScript error: <PYTHON EXCEPTION> *<class 'OSError'>: isc_stdout_write: PyArg_ParseTuple failed!

0
0 257