Dynamic Field Formulas

Dynamic Field Formulas

Introduction

With Dynamic Field Formulas, you can for example count values, create conditional clauses, edit fields’ information, etc. within a single CRM-service entity. With Dynamic Fields Formulas you can also seek information from an another module to the entity or count values for rows. It’s also possible to have a certain information field to show at the right side of the entity when the entity is opened and the condition is met. You can access the Dynamic Field Formulas in each module’s settings  or through SettingsModule Manager.

The formulas of dynamic fields are run when creating the entity, when information is fetched to other field or between clicking the Save button and the actual saving to the database. The detail view formulas are checked when the entity is opened in CRM.

If the formula is run either “On save” or “On field”, please note, that it is only run if the entity is saved in edit mode. Thus, the formula will not be run if the formula’s target field is edited with quick edit or mass edit, or data is imported to the field though CSV or integration.

With Run Formulas you can run all the formulas at once for the module you are in. This enables for example updating information and editing from field to another if there is for example a maintenance break. This function overwrites information in every existing entity in the module according to the formulas. You can run all the formulas for up to 5000 entities.

The formulas are run in the order they are shown on the list. You can change the order by dragging formulas up and down the list.

Creating New Formulas

You can create a new formula from New Formula button. In the field “Run” you can determine whether this formula is run eg. when the entity is created, when it’s saved or when information is collected to other field. In the field “Field” you determine the target field, where you want the value to be saved. In the “Formula” field you determine the wanted formula.

  • If the formula is run On save, the run is done every time the Save button is clicked after editing the entity.
  • If the formula is run On create, the run is done when the entity is first created.
  • If the formula is run On field, the run is triggered by a change in a certain other field. You can determine the triggering field from a pick list when creating the formula.
  • If the formula is run On Validation, the run is done when the Save button is clicked. The formula then checks the content of field and if the content is not valid, the formula displays a warning and interrupts saving the entity. A validation formula is done using this run option.

Under most modules you can also choose the run to be On view. Then the run is done when the Save button is clicked. A detail view formula is done with this option and it informs the user with a notification if the conditions of the formula are met. This notification is located at the right side of the saved entity. Note: if the formula is run “On view”, it allows saving the entity, contrary to the run “On Validation”. If these formulas are build based only on an if-clause, the information text is shown only when the if-clause is true. If there is also an else-clause, the formula can be built so that the information text is shown, when the else-clause is true.

If the field is set as success, the detail view looks like this:

If the field is set as information:

If the field is set as warning:

If the field is set as danger:

The new formula is activated by clicking the Activate option under the Actions header. Now the formula is active and does not need to be run using the Run formulas function. The pictures below represent an active formula (left) and a disabled formula (right).

Limitations

  • Dynamic formulas do not work on module tools. If the module tool should have some functionalities, they need to be determined with module tool parameters (more information on Module tools).
  • Dynamic formulas can only calculate results to fields which are editable or in the certain Read Only-format (if you have a setting “show in detail view only”, dynamic field formula cannot be used).
  • In modules that have row level fields (e.g. Invoices, Sales Orders, Quotes), the information on rows can not be used in a dynamic formula for a main level field or vice versa (read more about row level formulas further below).
  • Legacy only: Quick edit (single field edit) or mass edit do not activate dynamic formulas.
  • Legacy only: Dynamic formulas do not activate from importing data with a CSV file. (Another tool for triggering formulas when importing data is available via the support portal)
  • If you use “On field” option to run the dynamic formula, you need to have a field which collects the information from another module.

Dynamic Formulas in Row-Level Fields

You can also create dynamic formulas for row-level fields that e.g. quotes, sales orders and invoices have. This feature isn’t enabled by default, but you can activate it in Settings → Additional Settings by activating Enable inventory row field formulas field  in Row-Level Functions.

There are however a few limitations concerning the row-level fields’ formulas:

  • The row-level fields’ formulas can be run only either “On save” or “On create”.
  • In row-level fields’ formulas, you can not fetch information from the fields in the main level (e.g. the quote’s name, due date, or other “normal” fields) or vice versa.

Schedule dynamic field formulas

Formulas can be scheduled and run on the background for example to do calculations without opening and saving the entity. Learn more about how to do scheduled field formulas from here: Scheduled Tasks

Examples of formulas

Listed below, there are some examples of dynamic field formulas and when they usually should be run. The formulas in this guide are written using colour coding to visualize, which parts of the formula are most likely replaced to meet the specific need. The parts marked with blue are IDs of the fields in the module and they should be replaced to match the IDs of the fields actually used. The parts marked with orange represent a value of a certain field. The parts marked with red are variables that affect the final value of the target field. These variables could be for example a number to which the content of the field is compared or a message shown to the user if the content of the field is invalid.

For more examples of different formulas, see the guide Examples of dynamic field formulas.

 

Run On save

Updating the probability of the potential to 100% if the sales stage is changed to won

{if $sales_stage=='Closed Won'}100{else}{$probability}{/if}

The formula updates the value of the probability in the field “probability” to 100, if the status of the field “sales_stage” is “Closed Won”. Otherwise no changes are made.

 

Run On create

Setting a valid until date 14 days apart if the field is empty

{if $validtill ==''}{assign var='t' value='+ 14 days'|strtotime}{'Y-m-d'|date:$t}{else}{$validtill}{/if}

The formula checks if the field “validtill” is empty. If it is, the formula sets the value of the field to a date that is 14 days after the current date. If the field is not empty, no changes are made.

 

Run On field

Fetching the account number from account

{$account_id|getEntityFieldValue:'account_no'}

The formula fetches the account number of the account linked to the entity to this field. If the account number is changed on the account card, it will change in this field too.

 

Run On view

Notifying the user of a filled field

{if $passivation_date!= ""}The contact has a passivation date{/if}

The formula checks if the field “passivation_date” is empty. If is not, it notifies the user with an information text “The contact has a passivation date”.

 

Run On Validation

Giving notice of an invalid country code

{if $bill_country|count_characters > 2} The country code of the billing country is invalid. Finland = FI, Sweden = SE, Norway = NO and Denmark = DK {/if}

The formula verifies the length of the given country code and if the length is more than two characters, it notifies the user with a warning “The country code of the billing country is invalid…”. The entity is not saved.

Module Tools
CSV Import
Dynamic Field Formulas
Combined Shape