Global constants: Difference between revisions
Created page with "{{Beta}} {{WIP}} 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? == Resco partners that create OEM products with Resco technology often want to keep a master app project where most development is done. For each of their customers, they clone the master project and tweak it to match the specific ne..." |
|||
| (14 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{ | {{Rules TOC}} | ||
Woodford administrators can define project-specific constants. These can then be used in the business logic throughout the app project. Global constants require [[Releases/Fall 2024|release 17.2]]. | Woodford administrators can define project-specific constants. These can then be used in the business logic throughout the app project. Global constants require [[Releases/Fall 2024|release 17.2]]. | ||
== Why global constants? == | == Why global constants? == | ||
If you are an OEM/ISV partner managing complex projects with multiple variations, defining and using global constants across the entire project can save significant time and resources. In turn, this leads to faster deployment and more reliable outcomes. Allowing global constants 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 constants == | == How to define global constants? == | ||
To define global constants: | To define global constants: | ||
# Edit an app project and select '''Settings > Configuration''' from the Project menu. | # Edit an app project and select '''Settings > Configuration''' from the [[App_projects#Project_menu|Project menu]]. | ||
# Click '''Global Constants'''. | # Click '''Global Constants'''. | ||
# Define constants in the same way as you would define a variable in [[Rules_editor#Using_variables|rules editor]]. | # Define constants in the same way as you would define a variable in [[Rules_editor#Using_variables|rules editor]]. | ||
| Line 25: | Line 25: | ||
* String | * String | ||
== How to use constants == | == How to use global constants? == | ||
Constants can then be accessed in multiple places: | Constants can then be accessed in multiple places: | ||
;Rules | ;Rules | ||
* | * Available in rules configured using Woodford | ||
* | * Not available in other rules, e.g., in Report Designer or Questionnaire Designer rules | ||
;JSBridge | [[File:Using-constants-in-rules.png|600px|using global constants in rules]] | ||
;JSBridge - [https://github.com/Resconet/JSBridge/wiki/MobileCRM.GlobalConstants MobileCRM.GlobalConstants] | |||
Unlike variables, constants cannot be modified, neither in the Rules editor nor in Resco Mobile CRM. | * Use <code>MobileCRM.GlobalConstants.getAllAsync()</code> to retrieve a list of constants | ||
* Use <code>MobileCRM.GlobalConstants.getAsync("constantname")</code> to retrieve a particular value | |||
<syntaxhighlight lang="JavaScript"> | |||
<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> | |||
</syntaxhighlight> | |||
Unlike variables, '''constants cannot be modified''', neither in the [[Rules editor]] nor in [[Resco Mobile CRM]]. | |||
[[Category:Woodford]] | [[Category:Woodford]] | ||
Latest revision as of 11:46, 20 February 2025
| Rules and examples |
|---|
|
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 constants across the entire project can save significant time and resources. In turn, this leads to faster deployment and more reliable outcomes. Allowing global constants 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:
- Edit an app project and select Settings > Configuration from the Project menu.
- Click Global Constants.
- 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.
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
- Available in rules configured using Woodford
- Not available in other rules, e.g., in Report Designer or Questionnaire Designer rules
- JSBridge - MobileCRM.GlobalConstants
- Use
MobileCRM.GlobalConstants.getAllAsync()to retrieve a list of constants - Use
MobileCRM.GlobalConstants.getAsync("constantname")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.