On Data Change

Fires the flowchart logic when the record is changed. This is the Start Element of the flowchart.

Record is changed means that there was Save event of the entity – by a user through the interface, via API, or by other flowchart or custom logic_hook.

It doesn’t fire the flowchart when:

  • the change was made through the database directly
  • when one record is linked to another one via a many-to-many relationship type (use On Link Change for this).

inputs:

module – select directly in the operator the module which record change is in focus

  • Required: yes

event type – select when logic must be fired:

before_save –  executes before a record is saved (note that these changes aren’t seen through the interface directly on the View prior to the record being saved. Before save means that the logic is executed after the save event from the client-side but prior to actual save into database)

For Before Save logic please consider the following:

  • some fields values may not be set (e.g. the case_number field for the Cases module) as this business logic has yet to be executed.
  • do not use Save Entity for the Entity which is selected in On Data Change, as this entity will be saved by Sugar

after save – executes after a record is saved

  • Required: yes

outputs:

entity – a record where a change event has occurred. Here entity is in the state as it was saved by user/API/another flowchart or whatever executes the current flowchart. Commonly followed by Get Entity Attributes.

previous values – a record in a state of how it was before most recent changes, which fired this flowchart. Commonly followed by Get Entity Attributes and is compared with output from entity to check whether particular fields values were changed.

Apparently in after save logic the related fields that are part of the one-to-many relationship are always (each save event) empty in previous values. To get previous record use On Link Change.

is new – contains true when the record is new or false when this is an update of the existing one

changed fields – a collection of fields system names that were changed. Works only for after_save logic.

Note that each save event (even when the record was just opened and clicked save) contains date modified, modified_by_name.

Use this output carefully for new records, as in fields there are data about related objects which contain a huge amount of data to be output. When using for new records, specify exact fields that are in focus rather than output all.

Click to rate this post!
[Total: 0 Average: 0]

Leave a Reply

Your email address will not be published. Required fields are marked *