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

Question Scott Roth · Sep 12, 2019

After upgrading I ran a $SYSTEM.OBJ.CompileAllNamespaces("u"). What I got in return was kind of a shock.

In reviewing errors I am seeing code being referenced but no longer applies. It is referring to stuff that might of been defined in the Context , Formal Spec ,Thread , etc.

ERROR #5373: Class 'osuwmc.CPD.DataStructures.TblPharmacyDEA', used by 'osuwmc.CPD.BusinessOperation:SelectProviderTempDEA:FormalSpec', does not exist

ERROR #5373: Class 'osuwmc.FeederPat3BPLTest4', used by 'osuwmc.FeederPat3BPLTest4.Thread1:compileafter', does not exist

1
1 609
Question Virat Sharma · Sep 10, 2019

I am new to cache programming language . I am facing below issue . please assist.

Question: One persistent class ID column is a combination of its properties (Roll No and Marks) [ Exact: RollNo||Marks]. When i am running the query from Management portal it is displaying data in the same format and data is there. But in the code if i am making below statement, i am getting null value.

Set ExistsID=##Class(User.School).%ExistsId(RollNo_"||"_Marks)

set ID=##Class(User.School).%OpenId(RollNo_"||"_Marks)

8
0 1309
Question Rubens Silva · Sep 6, 2019

Hello,

I had an issue when using the method Exists, I noticed that if you provide a directory for this method it returns 1. This is really misleading, because sometimes the input could be a directory and the only way to predict this is to also test if the file is a directory.

I didn't tested using the Attributes method, but I supposed that this means could also be a solution for that issue. But still, I expected the Exists method to return 1 for files and 0 for directories, since there's also method called DirectoryExists already.

write ##class(%File).Exists("/InterSystems")
1
4
0 577
Question Dmitrii Kuznetsov · Sep 1, 2019

OAuth server to be deployed on the IRIS learning cloud platform. Clients - one on the other instance of the learning IRIS server, the other client locally on my computer in the container docker.

Both clients get a seemingly correct link (through ##class(%SYS.OAuth2.Authorization).GetAuthorizationCodeEndpoint()) to the login request form:  

3
1 1064
Article Maks Atygaev · Sep 6, 2017 5m read

The DeclarativeCOS project is a heartfelt cry about programming in the COS language.

The purpose of the project is to draw attention of the public to improving the inner core of COS.

The idea of the project is the support of a laconic syntax for cycles and collections.

So what is this laconic something that I have come up with? Welcome to the examples below!

Examples

The key concept underlying the project is the declarative approach to writing code. You need to specify WHAT should be used and HOW.

31
0 1945
Article Richard Zimmermann · Aug 21, 2019 2m read

Hello everyone,
After some work with IRIS we want to share our ToolBox-4-Iris with you.

What is this about?

The ToolBox-4-Iris is an API for IRIS with a collection of handy and useful tools - features that are not available in IRIS, but greatly simplify application development. To save time and effort on the "typical tools" that every developer needs. This includes additional classes, individual methods or even more efficient macros, which are described in the respective packages.

Content

Macros
General ObjectScript macros, Status macros, National Language Support macros, and JavaScript macros.

3
1 490
Question Vikram Annadurai · Jul 17, 2019

Hi Guys,

    I am new to Cache, I am trying to create an simple REST API on Studio and testing it with postman before that i have config the Web Application System > Security Management > Web Applications > Edit Web Application and i have attached my snapshot also with this post.

   When i testing it on postman i am getting "Service Unavailable" error. I really don't know where i did a mistake. I tried to console it on my code, when I the postman Url is not calling my code,So i think i did a mistake on my config part. Please give me some suggestion

Thanks in advance...

12
0 5635
Discussion Evgeny Shvarov · May 1, 2019

Hi Community!

Sometimes I meet a method which accepts 10+ parameters.

And often I need only the 8th parameter  to  pass. And I call the method something like:

do ##class(Some.Feature).Method(,,,,,,,"flag")

And I don't like this method when I call it like this cause, you know, often I just miss the number of commas and raise some other flag I wanted.

How do you avoid this situations? 

If you meet such a code, how do you call it and sure that you didn't miss the number of ","?

What is a good number of parameters in a method and f you need to pass more parameters in a method what do you do?

27
1 1856
Question Nic Lorenzen · Feb 28, 2016

Hello everyone!

Does anyone know of a library that can be used to create Mock objects for Objectscript classes?

Right now, my team has been building mock objects by hand to help circumvent dependencies when writing and executing unit tests, but I always wondered if someone had ever created a Mock library like Mockito to help quicken the process. 

Thanks!

4
0 1185
Article Rubens Silva · May 22, 2017 3m read

EDIT: This article has been updated with up-to-date information about the Port project, which now includes a tutorial for basic usage.
The Port project is something that I've introduced more than two years ago but I hadn't enough room to elaborate a tutorial on how to use it till now.


First, the motivation:

5
2 813
Question Stephen Wilson · Aug 21, 2019

The .NET Core Identity model has an IPasswordHasher<> interface for  for 

  • Hashing a password so that it can be stored in a database
  • Verifying a provided plain-text password matches a previously stored hash. 

I am getting invalid password errors during the login process when the .NET Core Identity model computes a hash from a plain text input and compares it to a password hash value I've returned from Caché. The default hashing algorithm is PBKDF2 with HMAC-SHA256, 128-bit salt, 256-bit subkey, and 10,000 iterations (detailed article on .NET Core Identity PasswordHasher). The algorithm Caché uses is probably different which may be why I am getting errors.

6
1 3206
Article Gevorg Arutiunian · Dec 13, 2018 2m read

(Originally posted by @Ben Spead on June 25, 2014)

This code snippet generates a list of Ensemble Lookup Tables and Schema documents in the user's current namespace. Run the code by running the class method "test":


Class benspead.EnsTablesSchema
{
	classmethod test() {
		If ##class(%Dictionary.CompiledClass).%ExistsId("Ens.Util.LookupTableDocument") {
		    // only supported in Ensemble 2012.1+
		    Write !,!,"Exporting Ensemble Lookup Tables..."
		    Set sc = $$$OK
		    Set rs = ##class(%ResultSet).%New("Ens.Util.LookupTableDocument:List")
		    Do rs.Execute()
		    While rs.Next() {
		        Set item=rs.Data("name")
		        Write "document found: "_ item,!
		    }
		    Do rs.Close()
		    Set rs=""
		}
		If ##class(%Dictionary.CompiledClass).%ExistsId("EnsLib.HL7.SchemaDocument") {
		    Write !,!,"Exporting Ensemble HL7 Schemas..."
		    Set sc = $$$OK
		    Set rs = ##class(%ResultSet).%New("EnsLib.HL7.SchemaDocument:List")
		    Do rs.Execute()
		    While rs.Next() {
		        Set item=rs.Data("name")
		        Continue:$listfind($lb("2.1.HL7","2.2.HL7","2.3.HL7","2.4.HL7","2.5.HL7","2.6.HL7","2.7.HL7","2.3.1.HL7","2.5.1.HL7","2.7.1.HL7","ITK.HL7")
		                            ,item)
		        Write "document found: "_ item,!
		    }
		    Do rs.Close()
		    Set rs=""
		}
	}
}

Here's a link to the code on GitHub: https://github.com/intersystems-community/code-snippets/blob/master/src/cls/benspead/EnsTablesSchema.cls

3
0 949
Article Jose-Tomas Salvador · Aug 14, 2019 5m read

Object Synchronization is a feature that has been around for a while, since Caché days, but I wanted to explore a bit more how it works. I've always thought that database automatic synchronization is complex by nature but, for some particular scenarios shouldn't be so hard. So I considered a very simple use case (OK, perhaps the typical one, I'm not discovering anything... but if it's common and it works, it's good ). You can download from GitHub and compile it into your system, generate sample data and play a bit with it. It's done for InterSystems IRIS but it also should work in last

1
2 570
Question Thembelani Mlalazi · Aug 15, 2019

I have a list property that I query from the database to get the values contained in that list using $LISTFROMSTRING() when the list is returned the list values contain a rectangle like character similar to when you copy past something to the Terminal and it has a preceding space .The problem is I need to compare those values to other values and they do not match because of this value I have tried to use $EXTRACT(value,*W) and *P but this is not striping the preceding character how do I get rid of this character any ideas please. 

the values returned from the Database 

3
0 676
Question Stephen Wilson · Aug 13, 2019

I have an OAuth 2.0 development environment where Caché is serving all three roles as the Authorization Server, Client and Resource Server based on a great 3-part series on OAuth 2.0 by @Daniel Kutac. I have a simple password grant type where an x-www-form-urlencoded body (as described in this post) is sent as a POST to the token endpoint at https://localhost:57773/oauth2/token and a response body with a HTTP Response 200 header is returned. The response body looks something like this.

3
0 2815
Question James Hipp · Jul 29, 2019

Hello,

I am struggling to print out the actual property values of the Security.System class.

https://cedocs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.c…

I was hoping to be able to print the Authentication Enabled properties of a system from the command line using the Get or GetProperties class method. Currently, however, I am only able to get a return 1 or Invalid Oref error.

I would expect one of these to work, but I think I am missing something. Any tips?

%SYS>w ##class(Security.System).Get("AutheEnabled")

1

%SYS>w ##class(Security.System).GetProperties("AutheEnabled")

5
0 425
Announcement Dmitry Maslennikov · Jun 10, 2019

Hi all, I have released the latest version of VSCode extension for ObjectScript already a month ago, and finally a time for the info about this new release.

So, what's new in the release:

What's new in this version

  • added export setting "objectscript.export.addCategory" if enabled uses the previous behaviour, adds category folder to export folder, disabled by default
  • added Server actions menu, by clicking on server info from status bar. Open Management portal, Class Reference and toggle connection.
  • Class Suggestion in ##class, Extends, As, CompileAfter, DependsOn, PropertyClass
  • $SYSTEM suggestion by Classes from %SYSTEM
  • Import and compile folder or file by context menu in File Explorer
  • Server Explorer, now possible to open any other namespace
  • Macros suggestion

For details how it works now, look further.

14
5 1057