#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 Robert Cemper · Aug 10, 2023 3m read

As noted in the previous article Native API has some limits.
So I did some research on a more Terminal-like interface that
provides me with access like a console or the IRIS terminal
to allow my  $QUERY over a global and other nice commands
that are not supported/mapped in NativeAPI for ObjectScript.

The basic tools are well-prepared and available.

  • Connection() creates a fully operational and stable partition for me
  • Function() allows calling any routine or method I need
  • similar ClassMethodValue and ClassMethodVoid

There is just no method CommandLine and some already prepared code is needed.

1
0 310
Question Pedro Lopes · Aug 9, 2023

Class Contatos.Amiguinho Extends %Persistent
{
Property Moradia As Cidade;

Relationship Trabalho As Contatos.Empresa [ Cardinality = one, Inverse = Nomedaempresa ];
}

------------------------Routine-----------------------------------
Set objcontato=##class(Contatos.Amiguinho).%New()
Set IDm=3,IDt=2
Set objcontato.Moradia=##class(Contatos.Cidade).%OpenId(IDm)    ;<-- it works for "Property Moradia As Cidade"
Set objcontato.Trabalho=##class(Contatos.Empresa).%OpenId(IDt)  ;<-- it doesn't works for "Relationship Trabalho As Contatos.Empresa"
Set ret=objcontato.%Save()

15
0 280
Article Robert Cemper · Aug 10, 2023 3m read

This question originally appeared in the comments of the post: Download globals from a particular server
 

This article was inspired by a recent question from @Evgeny Shvarov 
Download globals from a particular server
It is not a click-and-run code but a draft that requires adjustments for your special needs
you have  to add 

  • your credentials for server access
  • your level of error handling
  • Global name
  • the first set of subscripts as  %LB() block default=""
  • the last set of subscripts as  %LB() block default=""
  • a new global name if required default="" >> name not changed
1
0 339
Question Menno Voerman · Jul 13, 2023

Hi All,

We're doing our first babysteps with embedded Python and IRIS with an interoperability solution. We want to convert a CSV file to an Excel xlt file.

As service we've got a EnsLib.File.PassthroughService which picks up a csv file

As operation we've got a EnsLib.File.PassthroughOperation which writes the Excel file.

In the middle:

We've created an Business Process with an %Stream.GlobalCharacter in the Request and a %Stream.GlobalCharacter  in the Response.

3
0 565
Article Jimmy Xu · Jul 7, 2023 2m read

Hi Developers, I'm currently doing a demo about building a front end UI doing data analytics and setup a performance test with large data objects, therefore using "Populate Utility" could help me auto generate some sample data that I can play with.

Within this post I would like to share my experience of using Populate Utility, including using POPSPEC Parameter.

6
1 611
Article Satoshi Hosoi · Jul 27, 2023 1m read

InterSystems FAQ rubric

Whether the value of a local variable is an OREF or not can be determined using $IsObject(). Let v be the variable you want to check,

$IsObject(v)=1// v is an OREF$IsObject(v)=0// v is not an OREF$IsObject(v)=-1// v is an OREF but does not point to a valid object

Note that $IsObject(v) will give an UNDEFINED error if v is undefined.

To avoid UNDEFINED errors, it is recommended to use $Get like this:

$IsObject($Get(v))
0
0 459
Announcement Henry Pereira · Mar 27, 2020

SQLBuilder is a flexible and powerful SQL query string builder for InterSystems IRIS,

With SQLBuilder you have nice and clean object oriented methods, instead of having to use concatenation and substituition to generate dynamic queries.

A Dynamic SQL without SQLBuilder

A Dynamic SQL with SQLBuilder

If you like it, don't forget to vote in the IRIS Programming Contest

18
5 808
Question Michael Wood · Jul 18, 2023

I am trying to write a class method to return the value of a object element.  Input to method is the object and element. I am not getting a value returned. What am I missing?

ClassMethod GetObjectFieldValue(pObject As %DynamicAbstractObject, pField As %String) As %String
{
    quit:pObject="" ""
    quit:pField="" ""set tResponse=""
    set tResponse = pObject.%Get(pField)
    return tResponse

}

Here is my input data,

8
0 384
Article Gevorg Arutiunian · Mar 29, 2020 2m read

Now the Classes/Rutines/DeepSee files will be automatically exported to the working directory after saving or compiling and files will be automatically deleted .

<iframe src="https://www.youtube.com/embed/B1pmqAQqd4M" frameborder="0" allowfullscreen> </iframe>

Installation

To install isc-dev , you just need to download and import the file isc-dev.xml from last release. Some ways to import isc-dev .xml file:

  • Go to Management Portal -> System Explorer -> Classes -> Import and select the XML file.
  • Drag the file over Studio.
  • Terminal command:
NS>do $system.OBJ.Load("yourpath/isc-dev.xml","ck")
NS>zpm
zpm: NS>install isc-dev

How to enable this feature:

  • After importing the class in the target namespace, run the following method to set up the working directory:
NS>do ##class(dev.code).workdir("/path/to/your/working/directory/src/")
  • Go to Management Portal -> System Administration -> Configuration -> Additional Settings -> Source Control.
  • Select the target namespace and set the dev.FileManExtension class as the main one and save it.
  • Try to create a new class in the studio and save/compile it
  • Enjoy!
4
2 551
Question Jordan Simpson · Jun 23, 2023

Hi,

I'm trying to figure out why I'm unable to iterate through a dynamic array and access the nested objects.

Using the NHS PDS FHIR API in the NHS sandbox environment, I'm querying the PDS endpoint using a sample NHS Number to retrieve a patient's demographics. My Business Operation reads the response data and passes it back to my Business Process where I intend on iterating through certain nested objects. The data present in these nested objects will decide what happens next in the process.

In the JSON snippet below, I'm attempting to access the values of code and display.

4
0 919
Question Evgeny Shvarov · Jun 9, 2023

Hi folks!

How can I change the production setting programmatically?

I have a production that is a solution that uses some api-keys, which are the parameters of Business Operations but of course cannot be hard-coded into the source code.

E.g. here is the example of such a production that runs a connection of Telegram and ChatGPT.

And it can be installed as:

zpm "install telegram-gpt"

But now one needs to setup the key manually before using the production, having the following setting:

I'd like to set up it programmatically so one could install it as:

zpm "install telegram-gpt -D Token=sometoken"

How can I make it work?

18
0 1036
Question Scott Roth · Jul 6, 2023

I had attempted to create a REST Operation before but did not have success. As I am going through the Tutorials and Documentation everything references REST services, but I have a case where I want to create a REST Operation that makes Epic API calls against Interconnect. I have done SOAP operations before and we currently have one in our Production Namespace, but from what I understand SOAP has the wsdl which defines al the structures and etc, where REST does not. 

1
1 341
Article Hiroshi Sato · Jul 6, 2023 1m read

InterSystems FAQ rubric

The InterSystems ObjectScript language does not allow you to define methods of the same name with different arguments. It is generally classified as a programming language called a dynamic language.

In ObjectScript, you can freely control which arguments are used when executing a method, so unlike languages ​​such as Java, which are not dynamic programming languages, there is no need to strictly distinguish methods by the number of arguments at the compilation stage.

0
1 375
Article AndreClaude Gendron · Sep 19, 2017 1m read

It is with great pleasure that the CIUSSS de l'Estrie - CHUS is sharing the mocking framework it developed and presented at the InterSystems Summit 2017.  I will update this post with more detailed instructions in the next few weeks but I wanted to share the code and presentation quickly : 

https://gitlab.com/ciussse-drit-srd-public/Mocking-Framework

I hope you'll find this useful for your unit testing. We are using this extensively for the last 2 years and it really works well! The repo is public, feel free to submit enhancements!

14
1 2214
Question Menno Voerman · Jun 29, 2023

Hi All,

See code below. We don't want to %FromJSON interpret the data. 

We're creating a method to convert json to csv but we don't want to convert/interpret any of the data

The write in the code snipped below will give 220 as weight instead of 220.00.

Does anyone now a way/method to don't interpret the data without put "" on the values?

Class Tmp.test
{

ClassMethod help()
{
		set src = "{""name"" : ""greg"", ""weight"" : 220.00 }"set obj = ##class(%DynamicAbstractObject).%FromJSON(src)
     	write obj.name,!
     	write obj.weight,!
     	return$$$OK
}

}
2
0 275
Question Evgeny Shvarov · Oct 2, 2022

Hi folks!

How can I refer to a classmethod of the same class while coding another classmethod with Embedded python?

I know that I can call it with iris.cls(classname).MethodName(), but it's more cumbersome even comparing with ObjectScript, where I can call ..MethodName().

Compare ObjectScript:

do..SetupGame()

and the same call in EmbeddedPython:

    iris.cls('eshvarov.sample.SeaBattle.GamePython').SetupGame()

 

Thoughts?

6
0 455
Question Robbie Luman · Jun 27, 2023

Has anyone come across a good using Embedded Python to convert a Python List object to an IRIS %List object?

My use case is I want to open an SQL entry with an Objectscript class method, then pass some information from that row into a separate Python class method which will then create a Python List object, then have the Python class method return that list back to the Objectscript class method in such a way that the Python List can be converted to an IRIS %List object for me to then use in the Objectscript code.

3
0 490
Question Evgeny Shvarov · Jun 25, 2023

Hi folks!

I have a need to use symilar to $property function from Python. Here is the code:

obj=iris.cls('some.persistent.class')._New()

for property, value in data.items():

 $property(obj.property)=value ; I invented this

How could I do this? Any trick?

For now I plan to implement a helper function in iris that I will call, but I doubt also how can I transfer oref to IRIS.

Thoughts?

5
0 339
Question Evgeny Shvarov · Jun 25, 2023

Hi folks!

Consider I need to call a python function which name contains "_" symbol (which is quite often in Python). How it could be called from ObjectScript?

E.g. here is the code:

Set sm = ##class(%SYS.Python).Import("sample")

write sm.helloworld() ; function without _
white sm.hello_world() ; function with _ - won't compile.

Thanks in advance!

3
0 327