Dynamically change the theme of a project with the sc_set_theme macro

Á

Álvaro Moura

Last updated on Jul 6, 2026

Scriptcase provides macros, functions created by the developers of Scriptcase, which will assist in customizing applications as well as simplifying code editing at events.

In this article, we will see how to use the sc_set_theme macro in practice, to change the themes of your applications.

Using the sc_set_thema macro in Login

The macro changes the theme in the session, causing the change to be applied to all other applications until the session is finished or the theme changes again.

1. First, we must create a select field that must contain all the themes available for the change. The field name it's created is: set_theme

The listed themes must be previously added to the project.

The lookup method can be automatic, if there is a table with the name of the themes or manual, as in the example below.

  1. After creating the field, at the beginning of the onValidate event, insert the macro code as in the image below:

Here is the code that should be added.

  1. // Change the theme of the project application
  2. $theme = {set_theme};
  3. sc_set_theme($theme);

The macro accepts string sc_set_theme('ThemeName'); or verifiable location as in the example above.

Running the application

  1. Run the login application and select a theme.

  1. Click on ok, to execute the onValidity event, to change the theme.

The next application, in this example the form, will receive the selected theme.

How to keep the login with the default theme.

This macro changes the theme in the session, as previously informed. 

In this way, all applications will be displayed with the selected theme, including the login application.

To keep the login with the default theme, add the sc_set_theme macro to the onApplicationInit event stating the desired theme.

  1. sc_set_theme('BlueBerry');

If you would like the login theme to also be changed, just do not add the macro in the onApplicationInit event.