Encontrar

Article
· Nov 8 4m read

How to run a process on an interval or schedule?

When I started my journey with InterSystems IRIS, especially in Interoperability, one of the initial and common questions I had was: how can I run something on an interval or schedule? In this topic, I want to share two simple classes that address this issue. I'm surprised that some similar classes are not located somewhere in EnsLib. Or maybe I didn't search well? Anyway, this topic is not meant to be complex work, just a couple of snippets for beginners.

So let's assume we have a task "Take some data from an API and put it into an external database". To solve this task, we need:

  1. Ens.BusinessProcess, which contains an algorithm of our data flow: How to prepare a request for taking data, how to transform the API response to a request for DB, how to handle errors and other events through the data flow lifecycle
  2. EnsLib.REST.Operation for making HTTP requests to the API using EnsLib.HTTP.OutboundAdapter
  3. Ens.BusinessOperation with EnsLib.SQL.OutboundAdapter for putting data into the external database via a JDBC connection

Details of the implementation of these business hosts lie outside the scope of this article, so let's say we already have a process and two operations. But how to run it all? The process can run only by inbound request... We need an Initiator! Which one will just be run by interval and send a dummy request to our process.

Here is such an initiator class. I added a bit of additional functionality: sync or async calls will be used, and stop or not process on error if we have many hosts as targets. But mainly here it's a target list. To each item (business host) on this list will be sent a request. Pay attention to the OnGetConnections event - it's needed for correct link building in Production UI.

/// Call targets by interval
Class Util.Service.IntervalCall Extends Ens.BusinessService
{

/// List of targets to call
Property TargetConfigNames As Ens.DataType.ConfigName;

/// If true, calls are made asynchronously (SendRequestAsync)
Property AsyncCall As %Boolean;

/// If true, and the target list contains more than one target, the process will stop after the first error
Property BreakOnError As %Boolean [ InitialExpression = 1 ];

Property Adapter As Ens.InboundAdapter;

Parameter ADAPTER = "Ens.InboundAdapter";

Parameter SETTINGS = "TargetConfigNames:Basic:selector?multiSelect=1&context={Ens.ContextSearch/ProductionItems?targets=1&productionName=@productionId},AsyncCall,BreakOnError";

Method OnProcessInput(pInput As %RegisteredObject, Output pOutput As %RegisteredObject, ByRef pHint As %String) As %Status
{
    Set tSC = $$$OK
    Set targets = $LISTFROMSTRING(..TargetConfigNames)

    Quit:$LISTLENGTH(targets)=0 $$$ERROR($$$GeneralError, "TargetConfigNames are not defined")

    For i=1:1:$LISTLENGTH(targets) {
        Set target = $LISTGET(targets, i)
        Set pRequest = ##class(Ens.Request).%New()

        If ..AsyncCall {
            Set tSC = ..SendRequestAsync(target, pRequest)
        } Else  {
            Set tSC = ..SendRequestSync(target, pRequest, .pResponse)
        }
        Quit:($$$ISERR(tSC)&&..BreakOnError)
    }

    Quit tSC
}

ClassMethod OnGetConnections(Output pArray As %String, pItem As Ens.Config.Item)
{
    If pItem.GetModifiedSetting("TargetConfigNames", .tValue) {
        Set targets = $LISTFROMSTRING(tValue)
        For i=1:1:$LISTLENGTH(targets) Set pArray($LISTGET(targets, i)) = ""
    }
}

}

After it, you just need to add this class to Production, and mark our business process in the TargetConfigNames setting. 

But what if requirements were changed? And now we need to run our data grabber every Monday at 08:00 AM. The best way for it is using Task Manager. For this, we need to create a custom task that will run our Initiator programmatically. Here is a simple code for this task:

/// Launch selected business service on schedule
Class Util.Task.ScheduleCall Extends %SYS.Task.Definition
{

Parameter TaskName = "Launch On Schedule";

/// Business Service to launch
Property ServiceName As Ens.DataType.ConfigName;

Method OnTask() As %Status
{
    #dim tService As Ens.BusinessService
    Set tSC = ##class(Ens.Director).CreateBusinessService(..ServiceName, .tService)
    Quit:$$$ISERR(tSC) tSC
    
    Set pRequest = ##class(Ens.Request).%New()
    Quit tService.ProcessInput(pRequest, .pResponse)
}

}

Two important things here:

  • You must set the Pool Size of the Initiator Business Service to 0 to prevent running it by call interval (option Call Interval, you can clear or leave as is - it's not used when Pool Size is 0)

             

  • You need to create a task in Task Manager, choose "Launch On Schedule" as task type (don't forget to check a Namespace), set our Initiator Business Service name to the ServiceName parameter, and set up the desired schedule. See: System Operation > Task Manager > New Task

And a bonus

I often faced cases when we need to run something in Production only on demand. Of course, we can create some custom UI on CSP for it, but reinventing the wheel is not our way. I believe it is better to use the typical UI of the Management Portal. So, the same task that we created previously can be run manually. Just change the task run type to On Demand for it. On-demand task list is available at System > Task Manager > On-demand Tasks, see the Run button. Furthermore, the Run button (manual run) is available for any kind of task.

It is all. Now we have a pretty architecture of interoperability for our business hosts. And 3 ways to run our data grabber: by interval, on a timetable, or manually.

Discussion (0)1
Log in or sign up to continue
Announcement
· Nov 7

[Video] Document Server: Improving Performance While Reducing Stored Data

Hey Community!

We're happy to share a new video from our InterSystems Developers YouTube:

⏯  Document Server: Improving Performance While Reducing Stored Data @ Ready 2025
 

The presentation introduces the upcoming Document Server feature for InterSystems Cloud Document, a schemaless JSON database with SQL access. The new system uses two key innovations: Pack Vector Array (PVA): a compact, binary format for fast and efficient storage and retrieval and Common Key Map, which stores shared field names only once across similar documents. Together, these features significantly reduce storage size (up to 90% for deeply nested data) and improve query performance by enabling direct field access and faster indexing. This approach is especially useful for large, flexible datasets like medical records, offering both speed and efficiency in cloud document storage.

🗣 Presenter: Yiwen Huang, Data Platforms

Enjoy watching, and subscribe for more videos! 👍

Discussion (0)1
Log in or sign up to continue
Article
· Nov 7 8m read

Understanding SQL Window Functions (Part 1)

Window functions in InterSystems IRIS let you perform powerful analytics — like running totals, rankings, and moving averages — directly in SQL.
They operate over a "window" of rows related to the current row, without collapsing results like GROUP BY.
This means you can write cleaner, faster, and more maintainable queries — no loops, no joins, no temp tables.

In this article let's understand the mechanics of window functions by addressing some common data analisys tasks.

Discussion (0)1
Log in or sign up to continue
Question
· Nov 7

Try catch throwing error not actually throwing error to DTL in test or when run via router

Trying to check date in DTL. 

Want to throw a custom error not the default one from the $ZDTH. It does in the try as will write "Error" when testing the DTL but the actual error not showing. Report errors is turned on.  I also tried the THROW logic from best practices but that doesn't work either. $SYSTEM.Status.DisplayError(status) does display what the error should be returned. 

 try 
 {
    set tDateH = $ZDATEH(tDateofDeath, 8)
 }
 catch ex 
 { 
  w "error"
 set status = $$$ERROR($$$GeneralError,"Custom error message")
 do $SYSTEM.Status.DisplayError(status)
 do $System.Status.DecomposeStatus(status)  
    quit  
 }
5 Comments
Discussion (5)3
Log in or sign up to continue
Announcement
· Nov 7

Concours InterSystems « Réalisation des idées » 2025

Bonjour les développeurs,

Suite au succès retentissant du concours de l'année dernière, nous avons décidé de le renouveler. Bienvenue au

🏆 Concours « Réalisation des idées » 🏆

Soumettez une application mettant en œuvre une idée issue du portail InterSystems Ideas, ayant le statut Community Opportunity ou Future Consideration, créée avant la publication de cette annonce et nécessitant une programmation 😉

Durée : 17 novembre - 14 décembre 2025

Prix : $12,000$


Le sujet

Dans ce concours, nous attendons des applications qui mettent en œuvre n'importe quelle idée de votre choix issue du portail d'idées InterSystems et dont le statut est Opportunité communautaire ou Considération future, créée avant la publication de cette annonce.

Exigences générales :

  1. L'application ou la bibliothèque doit être entièrement fonctionnelle et originale. Il ne peut s'agir d'une simple importation ni d'une interface directe avec une bibliothèque existante écrite dans un autre langage (à l'exception du C++, où la création d'une interface IRIS nécessite un travail important). Elle ne doit pas être un copier-coller d'un projet existant ni inclure de code propriétaire. Elle ne peut pas utiliser les résultats de la rétro-ingénierie des produits d'InterSystems ni ceux de toute autre société. Veuillez consulter nos Conditions d'utilisation.
  2. Applications acceptées : nouvelles applications Open Exchange. Notre équipe examinera toutes les candidatures avant de les approuver pour le concours.
  3. L'application doit fonctionner soit sur IRIS Community Edition, soit sur IRIS for Health Community Edition. Les deux peuvent être téléchargés en tant que versions hôtes (Mac, Windows) à partir du site d'évaluation, ou peuvent être utilisés sous la forme de conteneurs extraits d'InterSystems Container Registry ou de Community Containers : intersystemsdc/iris-community:latest ou intersystemsdc/irishealth-community:latest .
  4. L'application doit être Open Source et publiée sur GitHub u GitLab.
  5. Le fichier README de l'application doit être en anglais, contenir le lien pour l'idée, les étapes d'installation, et soit la vidéo de démonstration ou/et une description du fonctionnement de l'application.
  6. Pas plus de 3 soumissions d’un développeur sont autorisées.

N.B. Nos experts auront le dernier mot quant à l'approbation ou non de la candidature au concours en fonction des critères de complexité et d'utilité. Leur décision est définitive et sans appel.

Prix ​​du concours :

1. Nomination des experts – les gagnants seront sélectionnés par l'équipe d'experts d'InterSystems :

🥇 1ère place - $5,000
🥈 2e place - $2,500
🥉 3e place - $1,000
🏅 4e place - $500
🏅 5e place - $300
🌟 6-10e places - $100

2. Gagnants de la communauté – candidatures qui recevront le plus de votes au total :

🥇 1ère place - $1,000 
🥈 2e place - $600
🥉 3e place - $300
🏅 4e place - $200
🏅 5e place - $100

❗ Si plusieurs participants obtiennent le même nombre de votes, ils sont tous déclarés gagnants et le prix est partagé entre eux.

❗ Les prix en espèces ne sont attribués qu'aux personnes pouvant justifier de leur identité. En cas de doute, les organisateurs contacteront le ou les participants pour obtenir des informations complémentaires.

 

Qui peut participer ?

Tout membre de la communauté de développeurs, à l'exception des employés d'InterSystems (sous-traitants ISC autorisés). Créer un compte !

Les développeurs peuvent s'associer pour créer une application collaborative. Autorisé de 2 à 5 développeurs dans une équipe.

N'oubliez pas de mettre en évidence les membres de votre équipe dans le README de votre application – profils d'utilisateurs DC.

Délais importants :

🛠 Phase de développement et d'inscription de l'application :

  • 17 novembre 2025 (00:00 EST): le concours commence.
  • 7 décembre 2025 (23:59 EST): la date limite de soumission.

 Période de vote:

  • 8 décembre 2025 (00:00 EST): le vote commence.
  • 14 décembre 2025 (23:59 EST): le vote se termine.

Remarque : Les développeurs peuvent améliorer leurs applications tout au long de la période d'inscription et de vote.

    Ressources utiles :

    ✓ Exemples d'applications et de bibliothèques :

    ✓ Modèles que nous vous suggérons de commencer par :

    ✓ Pour les débutants avec IRIS :

    ✓ Pour les débutants avec ObjectScript Package Manager (IPM) :

    ✓ Comment soumettre votre application au concours :

    Besoin d'aide ?

    Rejoignez la chaîne du concours sur le serveur Discord d'InterSystems ou discutez avec nous dans les commentaires de ce post.

    Nous avons hâte de voir vos projets! Bonne chance 👍


    En participant à ce concours, vous acceptez les conditions énoncées ici. Veuillez les lire attentivement avant de continuer.

     
     
    Discussion (0)1
    Log in or sign up to continue