#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 · Jul 20, 2020 1m read

t's also an example for a customized command extension (ZZJSON) in IRIS

IRIS has a nice %JSON.Formatter class.
But for debugging it is not really handy.
see:

ZWRITE js1  
js1="{""Name"":""Cunningham,John C."",""SSN"":""294-11-9150"",""DOB"":""1933-01-08"",""Home"":{""Street"":""4249 Ash Street"",""City"":""Tampa"",""State"":""MD"",""Zip"":""30176""},""FavoriteColors"":\[""White"",""Red"",""Green""]}"   

so you proceed for the most simple case

0
0 656
Question Peter N · Jul 11, 2020

I try to run a small test routine (guessing a random number) in WebTerminal but the result looks broken.
in IRISterminal:

 in WebTerminal:

I think it relates to backspace.
Is there some special setting required?

The code:

a
 q=".......... guess [0..9]: " 
 i=1:1 if ! $c(9),"thank you",! q
 q  
b
 !,i,$c(9),q
 f  v#1 q:(v?.1n) " !no number",$c(8,8,8,8,8,8,8,8,8,8,8,8)
 " "
 r=$R(10),p=$s(v="":1,v=r:"!",v>r:"<",1:">")
 x=q,$e(x,r+1)="*",$e(x,v+1)=$s(v=r:"!",v>r:"<",1:">") 
 q:p  $c(13),$c(9),p=v=q

5
0 349
Question Goran Stefanovic · Jul 6, 2020

I need to set and use some context variables in a transformation (written in DTL), but the code is manually written.

When writing the same as BPL I define context variables and they are visible in transformations called by that process.

In something like this my.DTLtransform sets HL7 message fields to values in context variables:

Set dtl = ##class(my.DTLtransform).%New()
Set qStatus = dtl.Transform(pRequest, .msg)
 

However, when I create a business process using custom code option, I don't see an obvious option, as well as documentation covering that area.

11
1 982
Question Jonathan Anglin · Jul 7, 2020

As I've become a little more familiar with HealthShare, I'd like to start exploring different ways of doing things. To date, the bulk of my data transformations have been using DTL; only using ObjectScript for a few operations that write to external SQL tables that were largely based on examples provided by my sales engineer.

4
0 477
Question Marc Mundt · Jul 2, 2020

I'm working with VS Code on Centos 8. When I install the ObjectScript extension the installation succeeds, but the InterSystems icon never appears in the left-side panel. I can change settings for the extension - set the server info, etc. No errors show-up in the VS Code debug log.

UPDATE: the same thing happens on MacOS when using VS Code 1.46.1 and InterSystems ObjectScript extension 0.8.6

Can anyone suggest next steps for me to troubleshoot? Is there another log I should check?

3
0 956
Question Craig Alexander · Jun 26, 2020

Hi all,

We are working on getting a number of non-code based configurations and settings in fully automated deployments, and I was wondering if anyone had any ideas on how to "update" a task that already exists.

What's in our repository is a separate file for each task in the standard .xml format for:
##class(%SYS.Task).ExportTasks($lb(tTaskID),"c:\TasksExport\"_tTaskName_".xml")

The problem is, the ImportTasks method doesn't update or overwrite if the task name already exists, and there's no DeleteTask method.

2
1 457
Question Yuri Marx · Jun 29, 2020

Set cdef = ##class(%Dictionary.ClassDefinition).%OpenId(table)
Set count = cdef.Properties.Count()
For i = 1:1:count {
      Write cdef.Properties.GetAt(i).Name, " ", cdef.Properties.GetAt(i).Type, "",  <MY QUESTION>,!
}
 

How can I do to get maxlen?

8
3 712
Question Mark O'Reilly · Jun 26, 2020

We have code with the line 

Set archiveFilePath=##class(Ens.Director).GetItemSettingValue("ReadPDFFileService","Adapter","ArchivePath",.status)

When we have this archivePath set as a System Default setting rather than Production definition setting i.e. shows in blue rather than black in the restore default screen it doesn't get the setting value. We want to get this value nomatter what way it is set. 

Running 2016 Healthshare

5
0 500
Announcement Anastasia Dyubaylo · Jun 13, 2020

Hey Developers,

We're pleased to invite you to join the next InterSystems IRIS 2020.1 Tech Talk: Using Java and .NETon June 16 at 10:00 AM EDT! 

In this installment of InterSystems IRIS 2020.1 Tech Talks, we put the spotlight on extending InterSystems IRIS with your own custom Java and .NET code. We will demo how to create a custom interoperability component with the new Productions Extensions (PEX) feature. Following that, we’ll demo how to call Java or .NET code from any ObjectScript code.

     

2
1 338
Question Joao Palma · Jun 19, 2020

Hi all

Does anyone have an easy way of reading the cdata in the xml response returned buy a Webservice?

At the moment I have a XML class and then I use read.Correlate() to read through that XML bit.  

However, depending on the message I have different things in the CData and I don't want to create a class for each one of these.

The API returns the cddata as KeyValueOfstringstring.

My idea would be to send to my method the cdata as a parameter which is the KeyValueOfstringstring part of the response message and then deal with it...

Any help would be appreciated...

Best Regards

4
0 640
Question Craig Regester · Jun 17, 2020

Good day all -

I am attempting to use the Data Transformation Builder (for ease of use for my other engineers) to build up a web service request object to send to an outbound operation. The source is a custom persistent class (extends Ens.Response, %JSON.Adaptor) and has serialized sub-class data elements and the request object is a custom persistent class (extends Ens.Request, %JSON.Adaptor.)

5
0 646
Question Jonathan Anglin · Jun 18, 2020

I have a code tag that performs some logic in a DTL, and want to add to it the ability to find the number of substrings delimited by a dollar sign ($) within a particular string. I have tried the following which compiles just fine, but generates an error when testing in the Data Transformation Builder.

set lineCount = $DCOUNT(reportBody,"$")

ERROR <Ens>ErrException: <SUBSCRIPT>zTransform+985^LH.IAMON.IAMONORU1XsformDTC2.1 *DCOUNT() Encoded subscript 1 > 511 bytes -- logged as '-' number - @' set lineCount = DCOUNT(reportBody,"$")'

3
0 951
Question Tim Miller · Jun 9, 2020

So we have a custom business service that we use and we are calling SendRequestSync.

Set tSC=..SendRequestSync(tOneTarget,tTargetStream, .tResponse)

For our response from our custom business operation, we send back an Ens.StringResponse.

set pResponse = ##class(Ens.StringResponse).%New()
set pResponse.StringValue = "File Delivery: "_tOutFilename_" of size: "_pRequest.Stream.Size_" (modified='"_pRequest.Stream.LastModified_"')"_" Status: "_tSC
 

3
2 629
Question Ting Wang · Jun 12, 2020

Hi Everyone,

We are trying to migrate old server to new infrastructure and need to sync all the DTL cls from old one to new one. There are hundreds of DTL in system and we tried to export from production but cannot select all at once which might cause some missing classes. Not able to connect to studio or atelier with that server neither. Is there any way that we are able to do mass export from system which will save some effort? Please let me know your thoughts. Thanks.

3
0 284
Article Evgeny Shvarov · Jun 12, 2020 3m read

Hi Devs!

Last weekend I had been testing the newborn csvgen module and was looking for a CSV file to test - thus I came across an interesting datafile on Data.World  with Game of Throne episodes statistics. Death statistics. These folks documented all the murders through all the 8 seasons and noted where, who, from what clan with what weapon had killed another one.

So I imported it and made an IRIS Analytics dashboard.

You Know Nothing, Jon Snow | You Know Nothing, Jon Snow | Know ...

Don't worry, Jon,  with this dashboard we can figure out something ). See the details below.

0
2 805
Question Olivier Champion · May 20, 2018

Hi

on this code

set reader=##class(%XML.Reader).%New()
    set statuscode=reader.OpenFile(file)
    if $$$ISERR(statuscode) {do $System.Status.DisplayError(statuscode) quit $$$NULLOREF}

I got this error "unable to open file 'https://www.musicxml.org/dtds/partwise.dtd'"

or using the xml schema wisard i got the error  https is active but no configuration found.

where do I have configure it?

5
0 497
Question Scott Roth · Jun 9, 2020

After all these years of doing basic Ensemble work, I am just beginning to venture into using Cache Tables instead of either Data Lookup tables, or what I know of Outside SQL tables using JDBC.  I have several Cache SQL tables that I am building for a project I am working on.  

  • I was wondering if it was possible to use a SQL call to look up a value against a Cache SQL table  within a Business Rule? 
  • Or is this something that I would have to build a custom function for? 
9
0 522