Skip to main content
Skip table of contents

What is the syntax for Oneapp formula

Formula Description

custom formulas supported in flutter

Formula

Parameters

Input

Output

Usage

Description

What is Inputs are NULL?

adddays

2

string, integer

DateTime

adddays(String, 2)

Add 2 days to the date mentioned and return dart datetime.
Allowed Format for date
mm/dd/yyyy

yyyy-mm-dd
yyyy-mm-dd 00:00:00.000

In the Case of

  1. Calculation formulas, “0” is used in the place of input.

  2. Formatting formulas: the formulas fail evaluation and the result is force to FALSE.

  3. Validation formulas: The condition evaluation fails and hence the “error message” is not shown to the user.

addhours

2

string, integer

DateTime

addhours(string, 2)

Add 2 hours to the date mentioned and return dart datetime.
Allowed format for date

Same as in adddays

In the Case of

  1. Calculation formulas, “0” is used in the place of input.

  2. Formatting formulas: the formulas fail evaluation and the result is force to FALSE.

  3. Validation formulas: The condition evaluation fails and hence the “error message” is not shown to the user.

ceil

1

integer or decimal

integer

ceil(param)

Round up the given parameter and return the integer.

In the Case of

  1. Calculation formulas, “0” is used in the place of input.

  2. Formatting formulas: the formulas fail evaluation and the result is force to FALSE.

  3. Validation formulas: The condition evaluation fails and hence the “error message” is not shown to the user.

cuberoot

1

integer or decimal

decimal

cuberoot(param)

Returns the cube root of passed parameter

In the Case of

  1. Calculation formulas, “0” is used in the place of input.

  2. Formatting formulas: the formulas fail evaluation and the result is force to FALSE.

  3. Validation formulas: The condition evaluation fails and hence the “error message” is not shown to the user.

datediff

2

Both can be reference or string

integer

Datediff([Reading].[Attribute], “2021-05-17”)

Returns difference between two times in hours.

In the Case of

  1. Calculation formulas, “0” is used in the place of input.

  2. Formatting formulas: the formulas fail evaluation and the result is force to FALSE.

  3. Validation formulas: The condition evaluation fails and hence the “error message” is not shown to the user.

days_from_lastreading

0

-

integer

days_from_lastreading()

Returns the number of days elapsed between today and last date with some data

In the Case of

  1. Calculation formulas, “0” is used in the place of input.

  2. Formatting formulas: the formulas fail evaluation and the result is force to FALSE.

  3. Validation formulas: The condition evaluation fails and hence the “error message” is not shown to the user.

exp

1

integer or decimal

decimal

Exp(param)

Returns e to the power param

In the Case of

  1. Calculation formulas, “0” is used in the place of input.

  2. Formatting formulas: the formulas fail evaluation and the result is force to FALSE.

  3. Validation formulas: The condition evaluation fails and hence the “error message” is not shown to the user.

factorial

1

integer

integer

factorial(param)

Returns factorial of param

In the Case of

  1. Calculation formulas, “0” is used in the place of input.

  2. Formatting formulas: the formulas fail evaluation and the result is force to FALSE.

  3. Validation formulas: The condition evaluation fails and hence the “error message” is not shown to the user.

floor

1

integer or decimal

integer

floor(param)

Rounds down the given parameter and returns the integer

In the Case of

  1. Calculation formulas, “0” is used in the place of input.

  2. Formatting formulas: the formulas fail evaluation and the result is force to FALSE.

  3. Validation formulas: The condition evaluation fails and hence the “error message” is not shown to the user.

if

3

Condition, param1, param2

param1 or param2

if (bool_condition, param1, param2)

If bool_condition is evaluate and return param1, else evaluate and return param2

In the Case of

  1. Calculation formulas, “0” is used in the place of input.

  2. Formatting formulas: the formulas fail evaluation and the result is force to FALSE.

  3. Validation formulas: The condition evaluation fails and hence the “error message” is not shown to the user.

isnull

1

reference

true or false

isnull([Reading].[Attribute])

Returns true is passed data is null else returns false

In the Case of

  1. Calculation formulas, “0” is used in the place of input.

  2. Formatting formulas: the formulas fail evaluation and the result is force to FALSE.

  3. Validation formulas: The condition evaluation fails and hence the “error message” is not shown to the user.

mod

 

2

Both can be integer or decimal

integer or decimal

mod(param1, param2)

Returns the remainder achieved by dividing param1 by param2.
mod(11, 3) will return 2

In the Case of

  1. Calculation formulas, “0” is used in the place of input.

  2. Formatting formulas: the formulas fail evaluation and the result is force to FALSE.

  3. Validation formulas: The condition evaluation fails and hence the “error message” is not shown to the user.

pow

2

Both can be integer or decimal

integer or decimal

pow(param1, param2)

Returns param1 to the power param2

In the Case of

  1. Calculation formulas, “0” is used in the place of input.

  2. Formatting formulas: the formulas fail evaluation and the result is force to FALSE.

  3. Validation formulas: The condition evaluation fails and hence the “error message” is not shown to the user.

rollover

2

reference, integer

integer or decimal

Rollover([endReading]-[beginReading], integer)

If [endReading]-[beginReading] is not positive, return [endReading]-[beginReading]+integer

If [endReading]-[beginReading] is 0 or negative, return [endReading]-[beginReading]

In the Case of

  1. Calculation formulas, “0” is used in the place of input.

  2. Formatting formulas: the formulas fail evaluation and the result is force to FALSE.

  3. Validation formulas: The condition evaluation fails and hence the “error message” is not shown to the user.

sqrt

1

integer or decimal

decimal

sqrt(param1)

Returns square root of parameter.

In the Case of

  1. Calculation formulas, “0” is used in the place of input.

  2. Formatting formulas: the formulas fail evaluation and the result is force to FALSE.

  3. Validation formulas: The condition evaluation fails and hence the “error message” is not shown to the user.

show_if

hide_if 

enable_if

disable_if

disable_and_clear_if

hide_and_clear_if

 

1

condition

true or false

show_if(condition)

The condition should be logical expression. Returns true if condition evaluates to true or else returns false

In the Case of

  1. Calculation formulas, “0” is used in the place of input.

  2. Formatting formulas: the formulas fail evaluation and the result is force to FALSE.

  3. Validation formulas: The condition evaluation fails and hence the “error message” is not shown to the user.

Average
(not supported)

2

reference, integer

decimal

average([Reading].[Attribute].children, 10)

Return the average of reference data for the past 10 readings. If number of readings are less than 10, then return the average of available number of readings.

In the Case of

  1. Calculation formulas, “0” is used in the place of input.

  2. Formatting formulas: the formulas fail evaluation and the result is force to FALSE.

  3. Validation formulas: The condition evaluation fails and hence the “error message” is not shown to the user.

Sum
(not supported)

2

reference, integer

decimal or integer

sum([Reading].[Attribute].children, 10)

Returns sum of past 10 readings, if available readings are less than10, return sum of available readings.

In the Case of

  1. Calculation formulas, “0” is used in the place of input.

  2. Formatting formulas: the formulas fail evaluation and the result is force to FALSE.

  3. Validation formulas: The condition evaluation fails and hence the “error message” is not shown to the user.

Variance
(not supported)

2

reference, integer

decimal or integer

Variance([Reading].[Attribute].children, 10)

Returns difference between current reading and average of past 10 readings.

In the Case of

  1. Calculation formulas, “0” is used in the place of input.

  2. Formatting formulas: the formulas fail evaluation and the result is force to FALSE.

  3. Validation formulas: The condition evaluation fails and hence the “error message” is not shown to the user.

 Syntax Rules

#

Syntax

Example

1

String can be written in double quotes or in single quotes, (double quotes is preferred)

“Attribute is required”
‘Attribute is required’

2

Allowed arithmetic operators 

 + ,   - ,   * ,   / ,   ~/ ,  % 

3

Allowed logical operators

 && ,  ||  ,  < ,  > ,  <= ,  >= , ==, !=, AND, and, OR, or 

(And, Or will result in failure)

4

External data can be referenced using square brackets

[ReadingView].[Attribute]

5

Parentheses are to be used for expression or formulas 

Sqrt(param) or (3*sqrt(100)) + 4

6

 Reference is case Sensitive

[Reading].[Picklist]  or [reading].[picklist] both will give different result

7

Functions are case insensitive

Average and average both will work

8

While referencing to picklist “.Value” can be used as extension for ID or “.Name” can be used as extension for picklist name. If no extension is provided, the default behavior is to use ID

[Reading].[Picklist].Name (picklist name)

[Reading].[Picklist].Value (picklist ID)
[Reading].[Picklist] (picklist ID)

9

While referencing to Gauges “.TankStrapping” can be used as extension for volume and “.Value” can be used as extension for inches. If no extension is provided, the default behavior is to use inches

[TopClose].TankStrapping (volume)

[TopClose] (inches)

[TopClose].Value (inches)

10

Extension can use or avoid square brackets

[Reading].[Picklist].[Name]
[Reading].[Picklist].Name

11

Extensions are case insensitive

.value or .Value both are supported
.name or .Name both are supported

12

Comma – (,) is used as delimiter between function parameters

Adddays(param1, param2)

13

Semicolon- (;) is used for validation formula. Use of commas in validation formulas will result in failure

Isnull([Reading].[Attribute]); “Reading is required”

14

Formulas can be nested inside other formulas

if(sqrt(param1) < 100, average([Reading].[Attribute], 10), average([Reading].[Attribute], 15))

15

The string on right hand side of the operator is case sensitive

[Reading].[Attribute] == “Well”
[Reading].[Attribute] == “well”
Both will result in different results

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.