Jump to content

Global constants: Difference between revisions

From Resco's Wiki
No edit summary
No edit summary
Line 4: Line 4:
== Why global constants? ==
== Why global constants? ==


For OEM/ISV partners who manage complex projects with multiple variations, the ability to define and use global variables across the entire project can save significant time and resources, leading to faster deployment and more reliable outcomes. Allowing global variables to be defined once and accessed across all UI components (views, forms, select rules) significantly reduces the manual effort needed to modify multiple parts of the project when creating variations of a master project.
If you are an OEM/ISV partner managing complex projects with multiple variations, defining and using global variables across the entire project can save significant time and resources. In turn, this leads to faster deployment and more reliable outcomes. Allowing global variables to be defined once and accessed across all UI components (views, forms, select rules) significantly reduces the manual effort needed to modify multiple parts of the project when creating variations of a master project.


== How to define global constants? ==
== How to define global constants? ==

Revision as of 05:47, 22 August 2024

Warning This page describes a function that has not yet been publicly released, or has been released in beta / preview quality. Subject to change.

Woodford administrators can define project-specific constants. These can then be used in the business logic throughout the app project. Global constants require release 17.2.

Why global constants?

If you are an OEM/ISV partner managing complex projects with multiple variations, defining and using global variables across the entire project can save significant time and resources. In turn, this leads to faster deployment and more reliable outcomes. Allowing global variables to be defined once and accessed across all UI components (views, forms, select rules) significantly reduces the manual effort needed to modify multiple parts of the project when creating variations of a master project.

How to define global constants?

To define global constants:

  1. Edit an app project and select Settings > Configuration from the Project menu.
  2. Click Global Constants.
  3. Define constants in the same way as you would define a variable in rules editor.
    • Click Variable.
    • Select the type and enter a name.
    • Assign a value.

define global constants in woodford configuration

The following constant types are allowed:

  • Boolean
  • Date Time
  • Decimal
  • Integer
  • String

How to use global constants?

Constants can then be accessed in multiple places:

Rules

using global constants in rules

JSBridge
  • Use MobileCRM.GlobalConstants.getAllAsync() to retrieve a list of constants
  • Use MobileCRM.GlobalConstants.getAsync("variablename") to retrieve a particular value
<script>
    MobileCRM.GlobalConstants.getAsync("stringEnv").then(o => {
        alert("stringEnv: " + o);
    });
    MobileCRM.GlobalConstants.getAsync("intEnv").then(o => {
        alert("intEnv: " + o);
    });
    MobileCRM.GlobalConstants.getAsync("boolEnv").then(o => {
        alert("boolEnv: " + o);
    });
    MobileCRM.GlobalConstants.getAsync("dateEnv").then(o => {
        alert("dateEnv: " + o);
    });
    MobileCRM.GlobalConstants.getAsync("decimalEnv").then(o => {
        alert("decimalEnv: " + o);
    });
        
    MobileCRM.GlobalConstants.getAllAsync().then(o => {
        let str = "";
        Object.keys(o).forEach(e => str += e + ": " + o[e] + "\n");
        alert("all: " + str);
    });
</script>

Unlike variables, constants cannot be modified, neither in the Rules editor nor in Resco Mobile CRM.