Expressions
Overview
Expressions are used in Govern OpenForms, version 6.0 and above to perform a wide variety of tasks within a Govern entity, such as:
- Performing a validation
- Performing a mathematical operation
- Performing a computation
- Executing a selection query
- Displaying the value of an unselected attribute on a form
- Attaching a condition to an entity or control; i.e., enabling it or making it visible only if a certain condition is met
Where to Add Expressions
Read More...Read Less...
Expressions can be added at the entity level and on most controls in the OFD.
They can also be associated with a calculated value for an attribute or a validation rule in the Business Entity Designer. Expressions that are added to the OFD are not saved in the database.
The correct syntax must be applied as described in the following table as well as the document available from the following link. The following topics are described in the document:
- General Procedures for Adding Expressions
- Deleting an Expression
- Types of Expressions
- Adding an Expression to a Govern Form
- Adding an Expression at the Entity Level
- Adding an Expression to a Control
- Applying Formatting to Expressions
- Adding Text in an Expression
- Displaying the Field Description
- For Further Reference
Documentation
To view or download this information as a pdf, click on the following links:
About Expressions
Expressions.pdf
Expression Reference
ExpressionReference.pdf
Notes
- Expression evaluation. We can test the expressions in the Expression Selector editor, before adding it to user or administrative form. When you enter your expression, the required parameters, including those inside queries, appear in a list. Enter applicable values to test the validity of the expression.
- Convert null parameters to default values. By default, all parameters that have a null value will now be converted to a default value (0 for numeric, empty string for strings, 01/01/0001 for dates). This means that you no longer need to use IsNull( ) around all your parameters. However, if you need the old behavior (to use different default values, for example) you just have to uncheck the “Convert null parameters to default values” option.
What’s New
- Variable: You can use a variable in an expression.
Expressions
Expressions are used throughout Govern OpenForms. They are created in the Expression Selector, available in various administrative forms in GNA, in the Business Entity Designer (BED) and in the OpenForms Designer (OFD). For detailed information, see OpenForms Designer and the Business Entity Designer (BED).
Expression |
Description |
Example / Syntax |
Result |
|
Abs |
Returns the absolute value of a specified number. |
|
|
Acos |
Returns the angle whose cosine is the specified number. |
Acos(1) |
0 |
Asin |
Returns the angle whose sine is the specified number. |
Asin(0) |
0 |
Atan |
Returns the angle whose tangent is the specified number. |
Atan(0) |
0 |
Case |
Evaluates the first parameter in the function and returns the first value that matches in the following list of options. |
Case(@attrID, |
when @attrID = 2 this returns ‘two’ |
|
|
1, ‘One’, |
|
|
|
2, ‘two’, |
|
|
|
3, ‘three’) |
|
Ceiling |
Returns the smallest integer greater than or equal to the specified number. |
Ceiling(1.5) |
2 |
Cos |
Returns the cosine of the specified angle. |
Cos(0) |
1 |
Date |
Returns the current date or the date part of a given date and time. |
Date() |
Returns the current date. |
Date(@attrDATE) |
Returns the date part of an associated attribute. |
Date(#11/26/2014 3:34:05 PM#) |
Returns 11/26/2014 |
DateAdd |
Adds to the current date and time the given number of years, quarters, months, weeks, etc. (either positive or negative). |
DateAdd(‘year’, 2) |
Returns the current date and time + 2 years. |
The list of available date parts is {Day, DayOfYear, Hour, Minute, Month, Quarter, Second, Weekday, WeekOfYear, Year}. The case is insensitive. |
DateAdd(‘year’, 2, @attrDATE) =>. |
Returns the date and time of the attribute + 2 years |
|
DateAdd(‘month’, -2) => Returns the current date and time – 2 months. |
|
|
DateAdd(‘year’, 2, @attrDATE) => Returns the given date and time + 2 years. |
|
|
DateAdd(‘month’, -2) => Returns the current date and time – 2 months. |
|
DateDiff |
Calculates the difference between two given dates and times (either positive or negative). |
DateDiff(‘year’, @attrDATE1, @attrDATE2) |
Returns the number of years between the dates and times of two associated attributes. |
The list of available date parts is {Day, DayOfYear, Hour, Minute, Month, Quarter, Second, Weekday, WeekOfYear, Year}.
These are case-insensitive. |
DateDiff(‘week’, @attrDATE1, @attrDATE2) |
Returns the number of weeks between the dates and times of two associated attributes. |
See https://msdn.microsoft.com/en-us/library/microsoft.visualbasic.dateinterval(v=vs.110).aspx for more details about
this list. |
DateDiff(‘minute’, @attrDATE1, @attrDATE2) |
Returns the number of minutes between the dates and times of two associated attributes. |
Day |
Returns the current day or the day part of a given date. |
Day() |
Returns the current day |
Day(@attrDATE) |
Returns the day part associated with an associated attribute. |
Day(#11/26/2014 3:34:05 PM#) |
26 |
Day(#11/26/2014#) |
26 |
Display |
Returns a string representation of the attribute value. |
‘Land Use Code: ‘ + @attrLUSE_CODE.Display |
Returns the item selected from the Land Use Code drop-down list. |
Double |
Returns the double representation, or a copy, of the value. |
Double(“7”) |
7 |
Exp |
Returns e raised to the specified power. |
Exp(0) |
1 |
Floor |
Returns the largest integer less than or equal to the specified number. |
Floor(1.5) |
1 |
|
|
Floor(3.5) |
3 |
|
|
Floor(-3.5) |
-4 |
Format |
Formats the first parameter using the style defined in the second parameter. |
Format(@attrAMOUNT, ‘c’) |
Returns the value in the attribute AMOUNT formatted as currency. |
Format(123.45, ‘0000.0’) |
Returns 0123.5 |
|
|
HasValue |
If the field contains a value, the expression returns True. Returns False if the parameter is Null or empty. |
HasValue(@attrBLDG_VALUE) |
Returns True if a value is entered in the Building Value field. If the field is empty or Null, returns False. |
IEEERemainder |
Returns the remainder resulting from the division of a specified number by another specified number. |
IEEERemainder(3, 2) |
-1 |
If |
Returns a value based on a condition. |
If(4/2 = 2, ‘abc’, ‘def’) |
‘abc’ |
In |
Returns true if an element is in a set of values. |
In(@attrId, 4, 5, 6) |
true when @attrId is 4, 5 or 6 |
IsNull |
If the parameter is Null, the expression returns the second parameter. Otherwise the first parameter is returned. |
IsNull(@attrID, 0) |
If @attrID is Null, a 0 is returned. |
IsNullOrEmpty ( ) |
If the parameter is Null or Empty, the expression returns the second parameter. Otherwise the first parameter is returned. |
IfNullOrEmpty(@attrID, 0) |
If @attrID is null or Empty a 0 is returned |
IsNullOrWhiteSpace ( ) |
If the parameter is null Or Empty Or White Spaces, it returns the second parameter. Otherwise the first parameter is returned. |
IfNullOrWhiteSpace(@attrID, 0) |
If @attrID is NULL or Empty or White Spaces, a 0 is returned |
Len |
Returns the length of the specified string. |
Len(‘Main Street’) |
Returns 11 |
Note that characters in the length are counted from one, starting index one. Use the Evaluate feature of the Expression Editor to test this. |
|
|
Ln(e) |
Ln(e) returns 1. |
Log |
Returns the logarithm of a specified number. |
Log(1, 10) |
0 |
Log10 |
Returns the base 10 logarithm of a specified number. |
Log10(1) |
0 |
Lower |
Converts all letters in the specified string to lowercase. |
Lower(‘Main Street’) |
Returns main street. |
Max |
Returns the larger of two specified numbers. |
Max(1, 2) |
2 |
Min |
Returns the smaller of two numbers. |
Min(1, 2) |
1 |
Month |
Returns the current month or the month part of a given date. |
Month() |
Returns the current month. |
Month(@attrDATE) |
Returns the month part of an associated attribute. |
Month(#11/26/2014 3:34:05 PM#) |
11 |
Month(#11/26/2014#) |
11 |
Now |
Returns the current date and time. |
Now() |
11/26/2014 3:34:05 p.m. |
Pow |
Returns a specified number raised to the specified power. |
Pow(3, 2) |
9 |
Query |
Executes a query and returns the first value in the first row. |
Syntax: |
Returns the result from GetParcelName. |
Note: As a best practice, write queries that return only one row and one column. |
Query(‘QueryName’) |
|
Example 1: Query(‘GetParcelName’) |
|
|
Syntax: |
Returns the result from GetQuantity with a maximum cache of 2 minutes. |
Query(‘QueryName’, n) |
Example 2: Query(‘GetQuantity’, 2) |
|
|
Syntax: |
Returns the tax map number from the first row of the results. |
Query(‘QueryName’, ‘ColumnName’) |
Example 3: |
Query(‘GET_P_ID’, ‘Tax_Map’) |
|
|
Syntax: |
Returns the tax map number from the first row of the results, with a maximum cache of two minutes. |
Query(‘QueryName’, ‘ColumnName’, n) |
Example 4: |
Query(‘GET_PARCEL_ID’, ‘Tax_Map’, 2) |
Round |
Rounds a value to the nearest integer or specified number of decimal places. The mid number behavior can be changed by using EvaluateOption.RoundAwayFromZero during construction of the Expression object. |
Round(15.5,0) Round(3.2222, 2) |
3.22 |
Round 0 |
Use the zero (0) to rounds to 0 decimal places using banker’s rounding: The value is rounded to the nearest even number. |
Round(16.5,0) |
16 |
Sign |
Returns a value indicating the sign of a number. |
Sign(-12) |
-1 |
Sin |
Returns the sine of the specified angle. |
Sin(0) |
0 |
Sqrt |
Returns the square root of a specified number. |
Sqrt(4) |
2 |
Str |
Returns the string representation of a value. |
Str(5) |
‘5’ |
Substr |
Returns a substring of the first parameter from the x-th character defined by the second parameter on a length defined by the third parameter. |
Substr(‘abcdef’, 2, 3) |
‘cde’ |
|
Note that characters in the substring are counted from zero, starting index zero. You can use the Evaluate feature on the Expression Editor to see how the characters are counted. |
Tan |
Returns the tangent of the specified angle. |
Tan(0) |
0 |
Truncate |
Calculates the integral part of a number. No rounding is applied. |
Truncate(1.7) |
1 |
Upper |
Converts all letters in the specified string to uppercase. |
Upper(‘Main Street’) |
Returns MAIN STREET |
Variable |
Creates a variable that can be added to an e-mail, for example. |
{
Name = ‘Govern’;
Amount = Query(‘getAmount’) + 500;
Tax = Amount * .15;
} |
Establishes variables for e-mails, etc. |
Year |
Returns the year part of a date. |
Year() |
Returns the current year. |
Year(@attrDATE) |
Returns the year part of an associated attribute. |
Year(#11/26/2014 3:34:05 PM#) |
2014 |
Year(#11/26/2014#) |
2014 |
Allowed Expressions
This section lists the expressions that are allowed in Govern OpenForms. The same interface is used for adding expressions throughout the Govern OpenForms Product Suite.
The list of expressions is available if you open the Expression Selector and hit [Ctrl] + the space bar. When you begin typing the first couple of letters of a syntax, a tooltip appears. The tooltip provides the same information as the following list.
For Further Reference
For further reference, refer to the following:
Numeric Formats
For numeric formats, see https://msdn.microsoft.com/en-us/library/y006s0cz(v=vs.90).aspx or https://msdn.microsoft.com/en-us/library/4fb56f4y(v=vs.90).aspx
Date Formats
For date formats, see https://msdn.microsoft.com/en-us/library/362btx8f(v=vs.90).aspx or https://msdn.microsoft.com/en-us/library/73ctwf33(v=vs.90).aspx
Dates and Date Parts
For dates and date parts, see https://msdn.microsoft.com/en-us/library/microsoft.visualbasic.dateinterval(v=vs.110).aspx for more details about this list.
Where to Add an Expression
The table on the following page lists the levels (form, entity, and attribute), and the controls (label, link, action button, groupbox, tab, etc.) and shows where you can add an expression for the user forms. Detailed information and examples are provided in the Govern OpenForms Designer and Business Entity Designer guides. This section provides a brief overview:
- Form / Business Model: Govern user forms are based on the business models created in the Business Entity Designer (BED). Expressions cannot be added to a business model or a user form (OFD form). They can be added to a business entity – a divider within a form – and to most controls.
- Business Entity: Business Entities are created in the Business Entity Designer (BED). They must be added to business models. You can add an expression as a validation rule in the BED, or the Record Description or the enabling or visibility properties in the OpenForms Designer (OFD).
- Custom Entity: Custom Entities are created in the OpenForms Designer (OFD) in order to add specialized controls or code to the form. You cannot add an expression to a Custom Entity. However, the custom entities must be added to a form with a root entity. You can add expressions to the root entity of the form.
- Attribute: Attributes are the data entry fields on a user form. They are created in the BED and added to business entities. They are mapped to database columns or can be stand alone. You can add an expression to an attribute as a default value, a calculated value, or as a validation rule in the BED, or the enabling or visibility properties in the OFD. If you want to perform a calculation that is not saved to the database, but is displayed on a form, you can create a stand-alone attribute or add a label to the form and add an expression to the label.
- Controls: Expressions can be added to the enabling or visibility properties of labels, links, action buttons, custom controls, groupboxes or tabs. They cannot be added to grids, rows, columns, or to custom entities. For further information, see the Govern OpenForms Designer and Business Entity Designer guides.
Level |
Application |
Type |
|
|
Form |
OFD |
N/A |
|
|
|
BED |
N/A |
|
|
Entity |
OFD |
Allow Save, Allow Delete |
Allow Update |
Record Description |
|
BED |
Validation Rule |
|
|
Attribute |
OFD |
IsEnabled |
IsVisible |
|
|
BED |
Validation Rule |
Default Value |
Calculated Value |
Label |
OFD |
IsEnabled |
IsVisible |
Expression (Any) |
|
BED |
N/A |
|
|
Link |
OFD |
IsEnabled |
IsVisible |
|
|
BED |
N/A |
|
|
Action Button |
OFD |
IsEnabled |
|
|
|
BED |
N/A |
|
|
Custom Control |
OFD |
IsEnabled |
IsVisible |
|
|
BED |
N/A |
|
|
Row or Column |
OFD |
N/A |
|
|
|
BED |
N/A |
|
|
Grid |
OFD |
N/A |
|
|
|
BED |
N/A |
|
|
Groupbox |
OFD |
IsEnabled |
IsVisible |
|
|
BED |
N/A |
|
|
Tab |
OFD |
IsEnabled |
IsVisible |
|
|
BED |
N/A |
|
|
Custom Entity |
OFD |
N/A |
|
|
|
BED |
N/A |
|
|
Examples
Expressions are used throughout Govern for different. Click on the Examples list to see different examples on how they can be used.
System |
Type |
Applicable to |
Description |
Examples |
BED |
Validation Rule |
Entities and Attributes |
Business Rules on Save |
bed01 |
|
Calculation & Formatting |
Numeric and Text Attributes |
Saved Attributes and Calculated Fields definition |
bed02 |
|
Properties (True/False) |
Business Entities and Attributes |
Sets properties (Is required / is audit / is central notes allowed … ) |
bed03 |
|
|
|
|
|
OFD |
On/Off (True/False) |
Visibility |
Set properties (Is enabled / Is visible for labels, fields, action buttons…) |
ofd01 |
|
On/Off (True/False) |
Security |
Set properties for (Allow delete / insert / save action buttons ….) |
ofd02 |
|
Entity |
Record Selector |
Defines Record selector (mini browse) info to display |
ofd03 |
|
|
|
|
|
GNA |
Profile Query (Coolbar) |
Coolbar Info |
Used to set conditional labels, action items, icons, links, etc. |
gna01 |
Videos
Click to link to a video preview of Using Expressions in Govern.
Click to see the “Become an Expressions Ninja” Video
See Also
In addition to the expression elements and functions developed by Govern, the Microsoft Codeplex Librairies Open Source project was integrated. An expression has access to the FORMS Attributes and Govern IDs. The expressions are binded to the form entity and are executed as soon as a change is detected. Logical Operands can be used and Govern Queries can be executed.
100-Expressions




(0 votes, average: 0.00 out of 5)
You need to be a registered member to rate this.
Loading...