Jump to content

Calculated fields: Difference between revisions

From Resco's Wiki
Created page with "{{WIP}} '''Calculated fields''' are entity fields that derive their value from other fields. == Prerequisites == On Resco Cloud, the minimum release supporting calculate..."
 
Marek Rodak (talk | contribs)
No edit summary
 
(7 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{WIP}}
{{Logic TOC}}
'''Calculated fields''' are entity fields that derive their value from other fields.
'''Calculated fields''' are entity fields that derive their value from other fields.
== Server-side ==
Calculated fields are an example of server-side [[business logic]]: the calculation is performed automatically on the server. In [[Resco mobile apps]], calculated fields are read-only. As a result, in offline mode, the calculated field might become out-of-date. When you sync your app, the calculated value from the server is downloaded to the app.
In general, we recommend against replicating the server-side logic in the app. After all, the offline database is never 100% up-to-date with server changes; calculations that involve additional records may not be reliable. In some scenarios, users of the mobile apps might be confused seeing that their calculated field isn't changing. For [[Mobile sales]], Resco mobile apps contain hardcoded logic that handles the issue. In other scenarios, one of the possible solutions is to create a shared variable calculated using the same formula as the calculated field and place it on the form instead of the calculated field.


== Prerequisites ==
== Prerequisites ==
Line 6: Line 12:
On [[Resco Cloud]], the minimum release supporting calculated fields is 16.1.
On [[Resco Cloud]], the minimum release supporting calculated fields is 16.1.


Similar features are available on other backends (formulas on Salesforce, calculated columns in Dataverse). These are (not?) supported in [[Resco mobile apps]].
Similar features are available on other backends (formulas on Salesforce, calculated columns in Dataverse). These fields can be enabled in Woodford and displayed in [[Resco mobile apps]].


== Supported field types ==
== Supported field types ==


The following field types can be calculated:
The following field types can be calculated on Resco Cloud:
* Two options
* Date and time
* Decimal number
* Floating point number
* Whole number
* Currency
* Single line of text
* Single line of text
* Option Set
* Multiple lines of text
* Two Options
* Whole Number
* Decimal Number
* Currency
* Date and Time


== Creating calculated fields ==
== Creating calculated fields ==


Calculated fields are managed using the [[Admin Console]].
On Resco Cloud, calculated fields are managed using the [[Admin Console]].
# Select '''Data > Entities''' from the menu.
# Select '''Data > Entities''' from the menu.
# Click the entity for that you want to create a calculated field.
# Click the entity for that you want to create a calculated field.
Line 35: Line 42:
The formula of calculated fields is defined using an interface similar to the [[rules editor]]. Use a combination of conditions and steps to determine the result.
The formula of calculated fields is defined using an interface similar to the [[rules editor]]. Use a combination of conditions and steps to determine the result.


[[File:Calculated field formula.png]]
[[File:Calculated field formula.png|alt=Calculated field formula]]


== Calculated fields in the app ==
== Calculated fields in the app ==


To see the results in the mobile app
To see the results in the mobile app:
# Edit your app project in Woodford.
# Edit your app project in Woodford.
# Enable the new calculated field(s).
# Enable the new calculated field(s).
Line 45: Line 52:
# Save all changes and publish the app project.
# Save all changes and publish the app project.
# Sync the mobile app and check the form.
# Sync the mobile app and check the form.
[[File:Calculated field result in the app.png|alt=Calculated field result in the app]]




{{Feedback}}
[[Category:Resco Cloud]]
[[Category:Resco Cloud]]
[[Category:Business logic]]

Latest revision as of 15:06, 14 November 2023

Calculated fields are entity fields that derive their value from other fields.

Server-side

Calculated fields are an example of server-side business logic: the calculation is performed automatically on the server. In Resco mobile apps, calculated fields are read-only. As a result, in offline mode, the calculated field might become out-of-date. When you sync your app, the calculated value from the server is downloaded to the app.

In general, we recommend against replicating the server-side logic in the app. After all, the offline database is never 100% up-to-date with server changes; calculations that involve additional records may not be reliable. In some scenarios, users of the mobile apps might be confused seeing that their calculated field isn't changing. For Mobile sales, Resco mobile apps contain hardcoded logic that handles the issue. In other scenarios, one of the possible solutions is to create a shared variable calculated using the same formula as the calculated field and place it on the form instead of the calculated field.

Prerequisites

On Resco Cloud, the minimum release supporting calculated fields is 16.1.

Similar features are available on other backends (formulas on Salesforce, calculated columns in Dataverse). These fields can be enabled in Woodford and displayed in Resco mobile apps.

Supported field types

The following field types can be calculated on Resco Cloud:

  • Two options
  • Date and time
  • Decimal number
  • Floating point number
  • Whole number
  • Currency
  • Single line of text
  • Multiple lines of text

Creating calculated fields

On Resco Cloud, calculated fields are managed using the Admin Console.

  1. Select Data > Entities from the menu.
  2. Click the entity for that you want to create a calculated field.
  3. Click New and select one of the supported field types, such as Whole Number.
  4. Enter new field details. As Source type, select "Calculated".
  5. Click Edit and enter a formula that defines how the field is calculated.
  6. Save all changes.

It is not possible to change the Source type of an existing field. You cannot change a simple field into calculated or vice versa.

Defining the formula

The formula of calculated fields is defined using an interface similar to the rules editor. Use a combination of conditions and steps to determine the result.

Calculated field formula

Calculated fields in the app

To see the results in the mobile app:

  1. Edit your app project in Woodford.
  2. Enable the new calculated field(s).
  3. Add the new field(s) to a form.
  4. Save all changes and publish the app project.
  5. Sync the mobile app and check the form.

Calculated field result in the app



{{#CI form: title = Was this information helpful? How can we improve? | type = inputs | [textarea] }}