4D Blog

Home Product Improved 4D Client Licenses Usage with Qodly Studio for 4D

Improved 4D Client Licenses Usage with Qodly Studio for 4D

May 2, 2024

Product

Those of you who have started using Qodly Studio for 4D  already know how powerful this new tool is for developing business web applications. If you haven’t yet, find here more information on getting started.

Apps made with Qodly Studio for 4D rely on the REST APIs. 4D 20 R5 is shipped with a great new feature: “Force Login” mode.

With Force Login mode, a 4D Client license is only consumed when users successfully log in and begin working with your application’s data and logic.

Keep reading to find out more! And don’t forget to download our demo to see it in action!

Demo Quit Session 

What is Force Login Mode?

Qodly web forms are not HTML. Indeed, Qodly Studio for 4D describes your form as a JSON file, later rendered in the end-user web browser as HTML.

For a Qodly form to be rendered in the end-user web browser, a REST request is triggered from the browser to download the form’s JSON from the server.

Further end-user actions on the form will also trigger REST requests to handle data and call functions of ORDA Data model classes on the server.

Before 4D 20 R5, as for any other REST requests, the server creates and maintains a web session to host the Session storage and session privileges, and a 4D Client license is consumed simultaneously.

Consequently, if you implement a simple authentication form (login + password inputs) with Qodly Studio for 4D, as soon as your end-user reaches this form, a 4D Client license is consumed before the authentication process has even started.

The consumed 4D client license is only released when the web session is closed after an inactivity timeout of at least one hour (or a server restart). This can lead to a lack of available 4D client licenses to allow users to work with your application.

We are aware this behavior could be enhanced, that’s why:

With 4D 20 R5, you can use the new “Force login” mode while working with the REST APIs.

This mode greatly benefits Qodly Studio for 4D applications as it improves this process. It helps you control the consumption of 4D client licenses, and you can now free a 4D client license when the user has finished using the application.

To summarize

With Force Login mode, licenses are consumed only when users start working with the s data and logic your REST server serves. This means:

  • Reduced License Consumption: Login forms no longer consume licenses.
  • Improved User Experience: Users can attempt login without impacting available licenses.
  • Better Resource Management: The license is freed once a user quits the application.

 

Free a 4D Client license at any time

The session can be quit by simply triggering the Logout standard action, and a 4D Client license can be released.

 

This is a significant enhancement, so let’s dive into more details to learn how you can benefit from this feature.

How to Activate Force Login Mode

Enabling Force Login mode is simple. Just navigate to the Roles and Privileges section and activate it.

blank

This updates your project’s roles.json file accordingly.

{
 "permissions": {
 "allowed": [
 ]
},
 "privileges": [
 ],
 "roles": [
 ],
 "forceLogin": true
}

Detailed Behavior Breakdown

Once this mode is activated:

  1. Descriptive REST requests (i.e., requests such as rest/$catalog or rest/$getWebForm to render a web form) do not consume any license.
  2. Other REST requests (e.g., requests handling data or calling ORDA Data model classes functions) are rejected until successful authentication is completed.
  3. You must implement a function whose name must be authentify() in the datastore class. This function handles the authentication. This is the only descriptive REST request accepted without a successful authentication.

 

Once the authentication is successful, all the REST requests are accepted, and a 4D client license is consumed.

A successful authentication means calling the Session.setPrivileges() function.

Here is the timeline of this:

blank

 

Example: Salesperson Application

This example features an application salespersons use to work with their customer’s files.

The end user renders a web form with a datasource of type entity selection (Customers dataclass) with the All initial value.

This error is received because no successful authentication has been done yet:

blank

blank

However, the end user can render this simple web form that does not handle data or call any function when loaded. No 4D Client license is consumed at this time.

 

blank

When the end user clicks on the Go button, the authentify() function is called. It has been implemented in the datastore class.

exposed Function authentify($credentials : Object) : Text
	
var $salesPersons : cs.SalesPersonsSelection
var $sp : cs.SalesPersonsEntity
	
$salesPersons:=ds.SalesPersons.query("identifier = :1"; $credentials.identifier)
$sp:=$salesPersons.first()
	
If ($sp#Null)
	If (Verify password hash($credentials.password; $sp.password))
		Session.clearPrivileges()
		Session.setPrivileges("")
		return "Authentication successful"
	Else 
		return "Wrong password"
	End if 
Else 
	return "Wrong user"
End if 

This call is accepted.

If the authentication fails, the Session.setPrivileges() function is not called. Thus, no license is consumed + no descriptive REST requests remain rejected.

If the authentication is successful, the Session.setPrivileges() function is called. Thus, a 4D client license is consumed, and any REST request is now accepted. You can then start working efficiently with your data.

Note: In this example, an empty string is passed to the Session. Use the setPrivileges() function to authenticate as a guest. Of course, the privileges corresponding to the users’ authenticating themselves can be set.

Further, you can offer your end users a disconnect feature thanks to the logout standard action mentioned above. The session will be cleared of its privileges, and the end user will be back in the “not authenticated state”: only descriptive REST requests are accepted, and they must authenticate themselves again to work with the data.

Conclusion

With Force Login mode in 4D 20 R5, you can optimize 4D client license consumption in your Qodly Studio for 4D web applications. This improves user experience and server resource management. Let us know what you think about this feature on the 4D Forums!

 

Discuss

Tags 20 R5, 4D Qodly Pro, ORDA, ORDA Data model classes, Qodly Studio, REST, REST server, Session, Web session

Latest related posts

  • June 16, 2025

    Generate, share and use web sessions One-Time Passcodes (OTP)

  • May 20, 2025

    Automatic Refresh of OEM Build Licenses

  • May 16, 2025

    New class to handle incoming TCP connections

Avatar
Marie-Sophie Landrieu-Yvert
- Product Owner - Marie-Sophie Landrieu-Yvert joined the 4D Product team as a Product Owner in 2017. In this role, she is responsible for writing user stories and translating them into functional specifications. She also ensures that the delivered feature implementation meets the customer's needs. Marie-Sophie graduated from the engineering school ESIGELEC and began her career as an engineer at IBM in 1995. She took part in various projects (maintenance and development projects) and worked as a COBOL developer. She then moved on to work as a UML designer and Java developer. More recently, her main responsibilities included analyzing and writing functional requirements, and coordinating business and development teams.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 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-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio 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