Skip to main content
Skip table of contents

How do I set up formulas using the iPhone Formula Engine?

Do NOT use Numerals in any Attribute Name , these are not usable within a formula and can cause the app to hang, slowdown or crash.

Setting up formulas

  1. Restore FDG app on mobile and go to any route-> stop-> stop Object -> click on the name on the navigation bar on top. Copy the Reading View.

  2. Go to Admin.

  3. Go to Reading Types on the left pane, and then go to Reading Views.

  4. Search for the name of the Reading View you copied in the search bar on top right.

  5. Click on the Reading View and the related attributes configured with the Reading View display at the bottom.

  6. Click on the attribute for which you want to set the formula and click edit.

    • Calculation formula: Check Calculated and enter the expression in the formula textbox, for example, if([TubingPressure]>100,100,[TubingPressure])

    • Carryforward formula: Select Carryforward type in the dropdown and enter expression in the Carryforward formula textbox, for example, if([TubingPressure]>100,100,[TubingPressure])

    • Custom validation formula:  Enter expression in the Validation formula textbox, for example, IsNull([Comments]);"Please Enter valid comments"

    • Custom formatting formula: Enter expression in the formatting formula textbox, for example, SHOW_IF([CasingPressure]>100)

  7. Click Update.

  8. Restore route of the object in which you made the changes in Admin so that your changes are reflected in the app.

  9. Edit any value for the same object to check if the updated formula is working correctly or not.

Constraints

  • Attribute names are supported in the format of [AttributeName] in custom validation and custom formatting. For calculation and carryforward, both [ReadingTypeName].[AttributeName] and [AttributeName] are supported.

  • Picklist value/names for reading attributes is supported as [DowntimeReason].Name == 'Yes' and Picklist value is only supported when the picklist is part of a EAV attribute of the object.

  • Calculation and carryforward are the same for all workspace readings. Calculations for events and tickets are handled differently which only supports daysFromLastReading and ADDDAYS and normal expression.

#

Name

Description

Usage

Validation

Formatting

Carry-forward

StopObjectEAV

Exceptions

IF

Follows- if(condition,true_statement,false_statement)

If Tubing Pressure was 120, this expression will return 100

if Tubing Pressure is less than 100, will return the value of Tubing Pressure.

Stop Object eav and Mass cf are not supported in inside if(...) condition.

if([TubingPressure]>100,100,[TubingPressure])

(tick)

(tick)

(tick)

(tick)

DATEDIFF

Returns difference in days between 2 dates.

DATEDIFF([UserDate1],[UserDate2])

Not Supported

  1. DATEDIFF(2018-05-25 00:00:00;2018-05-27 00:00:00) 

  2. DATEDIFF([Reading].[ReadingDate],2018-05-27 00:00:00)

  3. DATEDIFF([DATE1],2018-05-27 00:00:00)

(tick)

(tick)

(tick)

(tick)

  1. updated ; with ,

  2. Formulas involving constant dates (not coming from a variable) are not supported

ADDDAYS

  1. Adding n days to UserDate  (Date type) attribute

  2. Adding n days to date mentioned in the above format

ADDDAYS([UserDate],n) 

 Not Supported

  1. ADDDAYS(2018-05-25 00:00:00,n) 

  2. ADDDAYS([Reading].[ReadingDate],10) 

(tick)

(tick)

(tick)

(tick)

Formulas involving constant dates (not coming from a variable) are not supported

ISNULL

return true if no value is present

isnull([COMMENTS])

(tick)

(tick)

(tick)

(tick)

ADDHOURS

  1. Adding n hours to UserDate(Date type) attribute

  2. Adding n hours to date mentioned in the above format

  1. ADDHOURS([UserDate];n)

  2. ADDHOURS(2018-05-25 00:00:00;n)

  3. ADDHOURS([Reading].[ReadingDate],10)

(tick)

(tick)

(tick)

(tick)

VARIANCE

calculates average of n readings and compare current Volume value and returns the absolute difference between both

VARIANCE([Volume],n)

(tick)

(tick)

(tick)

(tick)

AVERAGE

will return average of last n readings, if some readings don't have value, for eg:- only 6 out of n readings have value, will add 6 readings and calculate their average only

AVERAGE([Volume],n)

(tick)

(tick)

(tick)

(tick)

SUM

It calculated sum of last n days reading,  if some readings don't have value, for eg:- only 6 out of n readings have value, will add 6 readings only.

SUM([Volume],n)

(tick)

(tick)

(tick)

(tick)

DAYS_FROM_LASTREADING

get days difference between current date and last known reading having some data

DAYS_FROM_LASTREADING()

(tick)

(tick)

(tick)

(tick)

SHOW_IF

Syntax: SHOW_IF(Condition)

If the condition evaluates to true, show the attribute that this is set as a formatting formula for. If the condition evaluates to false, the negation is Hide_and_clear_if which will hide(disable) the attribute and clear the attribute's value. On the workspace screen, since we can't hide one attribute for one day and show it on another day, we disable them. On events/tickets screen, we show/hide them.

SHOW_IF([CasingPressure]>100)

(tick)

(tick)

HIDE_IF

Syntax: HIDE_IF(Condition)

If the condition evaluates to true, hide(disable for workspace screen) the attribute that this is set as a formatting formula for. If the condition evaluates to false, the negation is Show_if which will show the attribute.

On the workspace screen, since we can't hide one attribute for one day and show it on another day, we disable them. On events/tickets screen, we show/hide them.

 HIDE_IF([CasingPressure]>100)

(tick)

(tick)

ENABLE_IF

Syntax: ENABLE_IF(condition).

If the condition evaluates to true, Enable the attribute for data entry. If condition evaluates to false, the negation is Disable_and_clear_if which will clear the value and disable the attribute for data entry. 

ENABLE_IF([CasingPressure]>100)

(tick)

(tick)

DISABLE_IF

Syntax: DISABLE_IF(condition).

If the condition evaluates to true, Disable the attribute for data entry without clearing the existing value. If condition evaluates to false, the negation is Enable_if which will enable the attribute for data entry.

DISABLE_IF([CasingPressure]>100)

(tick)

(tick)

DISABLE_AND_CLEAR_IF

Syntax: DISABLE_AND_CLEAR_IF(condition).

If the condition evaluates to true, disable the attribute for data entry and clear the existing cell value. If condition evaluates to false, the negation is Enable_if which will enable the attribute for data entry.

DISABLE_AND_CLEAR_IF([CasingPressure]>100)

(tick)

(tick)

Reading level metadata

Syntax: [Reading].[columnname]

We can access reading level field values using this syntax

Example: IsNull([Reading].[ReadingNumber])

(tick)

(tick)

(tick)

(tick)

(tick)

Object level metadata

Syntax: [Well].[ProducingMethod] / [Meter].[InstalledOn] etc

We can access object level properties (both EAV and columnar properties) using this syntax

Example: ADDDAYS([Meter].[InstalledOn],5)

(tick)

(tick)

(tick)

(tick)

Related Articles

JavaScript errors detected

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

If this problem persists, please contact our support.