4D Blog

Home Product REST and Qodly Support of Singletons

REST and Qodly Support of Singletons

September 5, 2024

Product

With 4D 20 R5, we released singletons. And with 4D 20 R6, we now allow you to directly call the exposed functions of your shared singletons through REST calls. Similarly, you can use the exposed functions of your shared singletons in events when designing your Qodly Pages. Let me delve deeper into these new capabilities.

HDI REST and Qodly Support of Singletons

Let’s say you want to create a REST service that is not linked to a specific data class.

Easy!

First, let’s create a shared singleton with an exposed function, the one you want to call through REST:

//class mySingleton

shared singleton Class constructor()
	
exposed Function myFonction($value : Integer)
	//code

Then, let’s look at the catalog by checking the JSON returned by myServer/rest/$catalog/$all. I see that my singleton just appeared with its exposed function:

"singletons": [
    {
      "name": "mySingleton",
      "methods": [
        {
          "name": "myFonction",
          "allowedOnHTTPGET": false,
          "exposed": true
        }
      ]
    }
  ],

I can now make a REST call to myServer/rest/$singleton/mySingleton/myFonction to directly execute my exposed function.
Of course, you can restrict calls to specific functions or singletons by configuring privileges in the roles.json file.

Inside Qodly, it’s even easier. When configuring events, you can choose your shared singletons exposed functions like any data class exposed function:

Qodly Studio shows my singleton inside the catalog and allows me to choose its exposed functions for events

And similarly, you can configure rights to execute singletons and their exposed functions through the privileges screen:

blank

Qodly Studio roles and privileges page allows me to configure my singleton’s access rights

If you want an easy-to-use example of what you can perform with singletons, I encourage you to check the HDI on singletons.

We hope these two features will ease your use of singletons.

If you have comments or remarks, don’t hesitate to bring them to our forum!

Discuss

Tags 20 R6, 21, REST, Singleton

Latest related posts

  • December 3, 2025

    Give AI to a 30 years old 4D application

  • November 28, 2025

    ORDA – Handle an event-driven logic during database operations

  • November 27, 2025

    ORDA – Permissions – Restrict / allow web access to the resources in one click

Nicolas Brachfogel
Nicolas Brachfogel
Product Owner & Senior Developer - Nicolas Brachfogel joined 4D in 2017 as senior developer (4D Server and networking) and as Product Owner to manage the 4D version on Apple Silicon. He is tasked with the redaction of user stories and functional specifications, as well as the verification that the new features are in line with customers' needs. With a degree from Institut Supérieur d'Informatique Appliquée Paris (INSIA), Nicolas started his career as a software developer in 2001. After many years of development in Java and C++, he specialized himself in client-server development in the video game industry. As a developer/software architect, he worked on the server architectures of many games (Dofus Arena, Drakerz, Trivial Pursuit Go !).
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy