Understanding This and this in Lowgile
This and this have different meanings in Lowgile. Their capitalization is significant, and they cannot be used interchangeably.
This document explains when to use each derivative in the different Lowgile contexts, including modules, the Console, entity methods, and screen actions.
Using This in Lowgile
Section titled “Using This in Lowgile”Capitalized This is a Lowgile alias.
It references the current application module and can be used wherever a module name would normally be required.
The following sections describe how to use This when referencing module objects, configuring screen variables, and writing Console code.
1. Replacing explicit module names
Section titled “1. Replacing explicit module names”Use This as shorthand when referencing an object defined in the current module.
For example, when the current module is Purchasing, the following reference:
This.PurchaseRequestis equivalent to:
Purchasing.PurchaseRequest2. Configuring screen variables
Section titled “2. Configuring screen variables”Use This when a screen variable references an object type defined in the current module.
For example, to configure a screen input variable that holds a PurchaseRequest object, set its Type in the Variables tab to:
This.PurchaseRequestTo create new PurchaseRequest object as the variable’s initial value, set its Default expression to:
new This.PurchaseRequest({}, true)This creates a new PurchaseRequest instance and assigns it as the variable’s initial value.
Using This in the Console
Section titled “Using This in the Console”In the Lowgile Console, This refers to the module currently selected in the module context selector.
For example, when the Purchasing module is selected, This.Materials refers to Purchasing.Materials
Attention
Do not use lowercase this as a replacement for the selected module. Use capitalized This in the selcted module context.
For more information about selecting a module context and executing code, see Use the Lowgile Console.
Using this in Lowgile
Section titled “Using this in Lowgile”Lowercase this is the standard TypeScript keyword.
Lowgile does not assign it a separate platform-specific meaning; its value depends on the context in which a function or method is called.
Unlike capitalized This, lowercase this does not represent a Lowgile module.
In this example, getName() is called as a method of item, so this refers to item and this.name accesses its name property.
const item = { name: "UP GM 203",
getName() { return this.name }}
return item.getName()Comparing This and this
Section titled “Comparing This and this”| Expression | Meaning | Typical use |
|---|---|---|
This.PurchaseRequest | References PurchaseRequest in the current Lowgile module. | Referencing object types, static entities, services, workflows, and other module-level objects. |
Purchasing.PurchaseRequest | References PurchaseRequest by using an explicit module name. | Cross-module references and Console code executed with the wildcard module context. |
this.name | Accesses the name property of the object represented by this. | Standard TypeScript and JavaScript methods and functions. |
The simplest way to remember the distinction is:
Thisanswers: Which Lowgile module?thisanswers: Which runtime object instance?
Tip
For help diagnosing errors caused by using the wrong form, see Troubleshooting This and this.