New post

Pesquisar

Article
· Mar 26 3m read

Create business processes with custom Python code: a quick guide

Hello interface engineers and app developers,     

Did you know that you can use Python in productions or integrations?

The production configuration user interface is low-code, but in many projects, you may reach a point where you need to write some code. As discussed in the Integration Architecture course, business processes are full of places for inserting code, specifically the BPL editor (for BPL business processes) and the DTL editor (for data transformations).

😯 As of InterSystems IRIS 2025.1, both Python and InterSystems ObjectScript are supported in the BPL and DTL editors. 😄 You can decide between these languages based on your personal preference, not technical necessity. 😍

Write Python in the BPL Editor

Python is supported in the BPL editor as of InterSystems IRIS 2024.1. Let’s look at a BPL business process:

A BPL business process, including the following activities in order: a start activity, an assign activity, a code activity with a Python logo on it, an if activity with a Python logo on it, a transform activity on the true side of the if activity, and an end activity.

On the <code> activity, GetWinningBid, notice the Python icon. Opening that <code> activity, we can see the field labeled Code has Python statements written in it! These code statements use the built-in iris library to open an object of a given ID.

A code activity from a BPL editor. The language is set to Python. The code says # Use request body to open Bid object with given ID. New line. bidID = request.id. New line. context.winningBid = iris.cls("AuctionServer.Bid")._OpenId(bidID).

You can set the language for the entire BPL—Python or ObjectScript—via the Language setting under the BPL’s General settings tab, and use the Language Override drop-down menu on a given code field to override the BPL default.

The <code> activity is not the only activity that parses code in a BPL business process. The <code> activity parses full code statements, but other fields in BPL activities also accept code expressions. You can recognize these by their Language Override drop-down menu, where you can override the BPL default. 

For example, the <if> activity, which creates a conditional logic flow, has a field called Condition which accepts code expressions. It has a corresponding field called Condition Language Override. In this example, this field is set to Python.

Before Python was supported in these fields, interface engineers needed to know how to write logical expressions in ObjectScript. For example, you needed to know that || means or, and && means and. Now you can use Python, whose syntax for logical expressions is closer to natural language.

In the BPL editor, if you need to import Python packages, you can do so under Python From/Import statements in the General tab.

Write Python in the DTL Editor

Python is also supported in code fields of the DTL editor as of InterSystems IRIS 2025.1. Common uses for custom code in DTLs are string formatting and calculations.

A DTL data transformation converting a source object, AuctionServer.Bid, into a target object, AuctionServer.Order

If you need to import Python packages in the DTL editor, find the Transform settings tab and use the Python From / Import statements field. The default language for code expressions can also be set in the Transform settings tab.

In the Transform settings tab of a DTL, the language is set to Python and the Python From / Import statements field says from numpy import random.

To find the code-parsing fields of DTL actions, simply find any field associated with a Language Override drop-down. For example, in the <code> action of a DTL, you can write full code statements. Actions including set, if, trace, and others support code expressions, which can be written in Python or ObjectScript.

A code activity from a DTL data transformation, with the language set to Python. The contents of the code field say bidders = [bid.User for bid in source.Lot.Bids()]. New line. bidders = set(bidders). New line. target.NumOutbid = (len(bidders) - 1).

Code-first workflows

If you are familiar with the process of editing productions via code, you can edit BPLs and DTLs via their configuration files. This is not as user-friendly as the editor interfaces, but it is straightforward for experienced programmers.

You can also use Python to write methods in custom utility functions and custom components , such as business operations and business services (except for callback methods, as described in documentation).

Summary 

  • The DTL editor and BPL editor now support Python code and expressions. 
  • If needed, declare which packages you want to import via the BPL or DTL’s general settings. 
  • You can set a default language for each DTL/BPL and override specific fields as needed.

Join the conversation!

  • Have you ever used Python when creating custom integrations? 
  • What questions do you have about Python support in integrations?
  • Add your comments below!
Discussion (0)1
Log in or sign up to continue
Article
· Mar 26 27m read

Plataformas de Dados e Desempenho da InterSystems – Parte 8: Planejamento de Capacidade e Desempenho de Infraestrutura Hiperconvergente

As soluções de Infraestrutura Hiperconvergente (HCI) têm ganhado força nos últimos anos, com o número de implementações agora aumentando rapidamente. Os tomadores de decisão de TI estão considerando HCI ao planejar novas implementações ou atualizações de hardware, especialmente para aplicações já virtualizadas no VMware.

Discussion (0)1
Log in or sign up to continue
Article
· Mar 26 5m read

Instalar WebTerminal en IRIS 2024.3

Las versiones recientes de IRIS contienen varios cambios que afectan a la instalación y condiguración de la herramienta OpenSource WebTerminal.

En este articulo, vamos a ver los pasos de instalación, y aprender a buscar y resolver los errores del WebGateway paso a paso.
Esta guía de instalación se ha realizado con la versiones siguientes, las más recientes soportadas a fecha de marzo de 2025:

  • Windows 2022 on Internet Information Server (IIS)
  • IRIS 2024.3 
  • Package Manager 0.9.2
  • WebTerminal 4.9.6

IRIS2024.3 es la primera versión de IRIS que no incluye un Servidor Web como parte de la instalación (con la excepción de las versiones "Community" de capacidades más limitadas, que siguen incluyendo un Servidor Web Apache para simplificar el "on-boarding"). En consecuencia, es importante instalar y configurar rimero el Servidor Web IIS antes de proceder a la instalación de IRIS. De esta manera, el instalador de IRIS detecta la presencia del IIS, y propose instalar/configurar un WebGateway que redirige las peticiones Web desde IIS a IRIS. Es posible realizar los pasos en orden inverso (instalar IRIS, despues instalar IIS), pero este requiere la instalación y configuración manual del componente Webgateway de InterSystems.

 

Guia Rapida para los impacientes

Algunos no querreis leer el articulo entero, resumo aqui los elementos principales de esta guía:

  • Instalar IIS primero
    • Añadir protocolo WebSockets
  • Instalar IRIS
    • con la opción de modificar la configuración de IIS
  • Instalar el ZPM en IRIS con
    • s version="latest" s r=##class(%Net.HttpRequest).%New(),r.Server="pm.community.intersystems.com",r.SSLConfiguration="ISC.FeatureTracker.SSL.Config" d r.Get("/packages/zpm/"_version_"/installer"),$system.OBJ.LoadStream(r.HttpResponse.Data,"c")
  • Configurar el ZPM para que acceda a los package del community
    • zpm "enable -community"
  • Instalar WebTerminal en el namespace USER
    • zpm "install webterminal"
  • Añadir el privilegio Publico de "READ" sobre el recurso %DB_USER 
  • en IIS:
    • Añadir las aplicaciones /terminal y /terminalsocket a IIS. Redigirlas para usar el module CSPms del Webgateway, sin verificar si el archivo existe.
  • Connectar con   

Y Ahora, pasamos a la guía completa con más detalles...

 

Instalación y configuración de IIS

 Un requerimiento del WebTerminal es el uso de WebSockets, protocolo que no esta habilitado por defecto en IIS.

 

El Windows Server Manager permite añadir "Roles de Servidor", e instalar IIS:

Se escoge IIS:

 

Y en las opciones siguientes, se despliega "Aplication Development" para escoger la opción de "WebSockets":

 

Instalación de IRIS

Se instala IRIS 2024.3. Como ya esta instalado IIS, en un paso del Wizard de instalación, se pregunta si se quiere configurar IIS. Este paso instala y configura el InterSystems WebGateway como Modulo de IIS:

 

Instalación del Package Manager IPM

El codigo y la documentación de InterSystems Package Manager (IPM anteriormente ZPM)  esta en

https://github.com/intersystems/ipm

Para la instalación, se puede usar el comando descrito en el README.MD de github

s version="latest" s r=##class(%Net.HttpRequest).%New(),r.Server="pm.community.intersystems.com",r.SSLConfiguration="ISC.FeatureTracker.SSL.Config" d r.Get("/packages/zpm/"_version_"/installer"),$system.OBJ.LoadStream(r.HttpResponse.Data,"c")

Y Despues, usar el siguiente comando para permitir el acceso al los Packages de la communidad y habilitar el Package Manager en todos los namespaces

zpm "enable -community"

 

Instalación del WebTerminal

 

zpm "install webterminal"

En este paso, se puede validar que el aceso al WebTerminal todavia no esta operacional, ya que IIS + el Webgateway no redirigen la URL /terminal/ a la instancia de IRIS

http://127.0.0.1/terminal/

Abrimos la aplicación de configuración de IIS, para añadir las 2 aplicaciones Web Siguientes

Aplicación
/terminal
/terminalsocket

/terminal y /terminalsockets:

 

A Continuación se debe definir el handler Mapping para esta aplicación, de manera que todas la peticiones estén gestionadas por el WebGateway:

 

Además, en el "Request Restrictions", es importante permitir las llamadas sin validar que exista un fichero correspondiente. Esto se hace sacando el "check" al "Invoke handler only if request is mapped to:".

 

Con estos cambios realizados, el IIS ya reenvia las peticiones http://localhost/terminal/ al WebGateway, y la configuración por defecto del Web Gateway redirige estas peticiones a IRIS. 

Se puede validar este paso haciendo una traza de las peticiones del Web gateway mediante la pagina de configuración disponible en http://localhost/csp/bin/system/Module.cxw 

En el menu "View HTTP Trace" s puede ver la petición y la respuesta de IRIS (un Error 401).

 

En IRIS, se puede investigar la causa del error 401, con las paginas del Audit, que informan de la naturaleza del error interno:

 

Menu de Portal de Gestión "Administration" / "Security" / "Auditing" / "Configure System Events".

  • Para ello, hace falta añadir el "System Event" de "Protect" a la lista de Eventos a registar, y cambiar su estado a "Yes":

 

Desde el Log de Audit, haciendo una búsqueda sobre los últimos errores, podemos ver 2 errores vinculados con la peticion a /terminal/:

Y los detalles del Error Protect:

 

La Aplicacion WebTerminal ha sido instalada en el namespace "USER", cuya base de datos esta protegida por el recurso "%DB_USER". El CSP Gateway, cuando establece la conexión e intenta acceder a la aplicación REST /terminal en este namespace, necesita permisos de lectura para responder a las peticiones HTTP Options (preflight requests para CORS).
La solución es dar el permiso publico de Lectura sobre el recurso %DB_USER:

Se hace con el menu "System" /" Security" / "Resources", seleccionando %DB_USER, y añadiendo "Read" como permiso publico.

 

Y finalmente, se puede volver a hacer la prueba y acceder al terminal, introduciendo usuario y password:

http://localhost/terminal/
Discussion (0)1
Log in or sign up to continue
Question
· Mar 26

"Bad value for type long" on select from PostgreSQL via EnsLib.SQL.OutboundAdapter

Here is my code:

Method getStocks(pRequest As Stock.Message.Req, Output pResponse As Ens.StreamContainer) As %Status
{
     s tSC = pRequest.NewResponse(.pResponse)
     q:$$$ISERR(tSC) tSC

     #dim pRS As EnsLib.SQL.GatewayResultSet

     s tSC = ..Adapter.ExecuteQuery(.pRS, "select jsonb_agg(s) #>> '{}' FROM prod.stocks s where s.""Warehouse"" = ?", pRequest.Warehouse)
     q:$$$ISERR(tSC) tSC

     s pResponse = ##class(Ens.StreamContainer).%New()
     s pResponse.Stream = ##class(%GlobalCharacterStream).%New()

     i pRS.Next() {
          d pResponse.Stream.CopyFrom(pRS.GetDataStream(1))
     else {
          s tSC = $$$ERROR($$$GeneralError"ResultSet is empty")
     }

     q tSC
}

I created BO with EnsLib.SQL.OutboundAdapter, created DSN and seated it in operation settings. I am using a postgresql-42.7.4 JDBC driver. When I ran it, I got an empty record set error in trace and next record in Java Gateway log:

Sent: (10:12:08:696) [Job number = -1] [ThreadID = 10]
  0000:  4A  13  7E  00  00  00  00  00  00  00  00  00  59  4D      J.~.........YM
  000E:  00  00  00  43  13  7E  00  02  52  00  65  00  6D  00      ...C.~..R.e.m.
  001C:  6F  00  74  00  65  00  20  00  4A  00  44  00  42  00      o.t.e. .J.D.B.
  002A:  43  00  20  00  65  00  72  00  72  00  6F  00  72  00      C. .e.r.r.o.r.
  0038:  3A  00  20  00  42  00  61  00  64  00  20  00  76  00      :. .B.a.d. .v.
  0046:  61  00  6C  00  75  00  65  00  20  00  66  00  6F  00      a.l.u.e. .f.o.
  0054:  72  00  20  00  74  00  79  00  70  00  65  00  20  00      r. .t.y.p.e. .
  0062:  6C  00  6F  00  6E  00  67  00  20  00  3A  00  20  00      l.o.n.g. .:. .

[Update 1] The problem is: Why does Java Gateway try to read a text (varchar) type field as a long type?

[Update 2] The reason is not in a big text value of the selected field. I tried to limit records for json and got the same error

3 Comments
Discussion (3)2
Log in or sign up to continue
Article
· Mar 26 7m read

Génération des spécifications OpenAPI

Introduction

Une API REST (Representational State Transfer) est une interface qui permet de faire communiquer différentes applications entre elles via le protocole HTTP, en utilisant des opérations standard telles que GET, POST, PUT, et DELETE. Les API REST sont largement utilisées dans le développement de logiciels pour exposer des services accessibles par d'autres applications, permettant ainsi l'intégration entre différents systèmes.

2 Comments
Discussion (2)1
Log in or sign up to continue