The Musings of Chin - Different Practices: Ways to Update a Field

From SmartWiki
Jump to: navigation, search

In the latest installment of Chin's Musings, he discusses different methods of updating the values of fields in SmartSimple.

Let's learn about some different ways that you can update a field.

SmartSimple is continually becoming more robust and enhanced with new features. This sometimes results in the ability to configure the same end functionality through the use of a variety of different techniques. This article will discuss different ways that you can update a field value to help you decide on the best approach for your situation.


Default Text

The simplest way to store a value into a field. This is configured through the custom field settings page for open text input fields such as Text - Single Line. This setting works by populating the input field on the form with the specified default value when a field does not already have a value stored in it. This requires the user to save the form to actually save the field value.

Advantages:

  • Simple and efficient
  • Flexibility offered through custom field configuration (i.e. can be used as a one-time store and not allow users to edit the default field value and can be hidden/shown on page, or alternatively allow users to edit the default field value)
  • Visibility (i.e. users can see the field and verify the default value before it is actually saved and stored into the field)


Calculated Value Field

A way to update a field based upon an expression that is run on page load. This applies only to the Special - Calculated Value custom field type. This setting is configured using JavaScript syntax and works by populating the input field on the form with the specified expression every time the form is loaded. This requires the user to save the form to actually save the field value.

Advantages:

  • Simple and efficient
  • Complex calculations can be performed via JavaScript syntax
  • Sequential processing (i.e. on page load, each Calculated Value field is evaluated in order of their display order)
  • Visibility (i.e. users can see the field and verify the default value before it is actually saved and stored into the field)


Value Stores To

A way to duplicate a field value and store it into another field. This is configured through the custom field settings page. This setting works by duplicating a field value into another field any time the first field is saved. This requires the user to save a value into the first field.

Advantages:

  • Simple and efficient
  • Synchronization (i.e. in the case that you have multiple fields that represent the same data set this can be used to synchronize the values between these fields)
  • Transparency (i.e. works behind the scenes)


Template Formula

A way to update a field value behind the scenes. This is available in various areas and can be configured through the UTA settings page, User Roles, or Company Categories pages. This setting is configured using MySQL syntax and works by directly updating the stored value of a field. This requires the user to save the form and runs after the form is saved, thereby referencing the latest field values that were saved.

Advantages:

  • Ability to update different areas other than the form the user is directly on (i.e. a L2 formula can be used to update an L1 field)
  • Server side validity (i.e. can be used for date/time functions to reference server time at exact time of saving)
  • Complex calculations can be performed via MySQL syntax
  • Sequential processing (i.e. saving an L3 results in L3 formulas, then L2 formulas, then L1 formulas to be run consecutively. Also within a template formula block, each individual line is processed consecutively thus allowing you to update a field value in one line, and then reference the new field value in the next line)
  • Transparency (i.e. works behind the scenes)

Workflow Task: Update Custom Field

A way to update a field value behind the scenes. This is configured as a task within a Workflow. This requires the Workflow to be triggered against the object whose field you wish to update.

Advantages:

  • Ability to update different areas other than the form the user is directly on
  • Server side validity (i.e. can be used for date/time functions to reference server time at exact time of Workflow run time)
  • Inherent audit trail of when the workflow was triggered and who triggered it
  • Sequential processing (i.e. ability to process other Workflow tasks before or after. Note: while Workflow tasks run sequentially, the Workflows themselves run asynchronously on the server)
  • Transparency (i.e. works behind the scenes)