# Persist Status

reviewed: 10 March 2025

BO Persist Life Cycle

Each instance of a business object uses an internal status field to keep track of the persist life cycle. There are 3 persist statuses:

  • CLEAN : The BO has just been created or loaded from the database (including an iteration over an iterator.ofEntity())
  • NEW : The BO has been reset (bo.reset()) or had its' automatics set (bo.setAutomatics())
  • DELETED : The BO has been deleted (bo.delete())

The persist status serves a number of purposes:

  • Decide what bo.persist() should do (see next paragraph)
  • Decide whether dynamic attributes need to be re-evaluated
  • Decide whether we need to attempt to load attributes in case of an ensureLoadGroup

Of which the bo.persist() purpose is the most visible.

The bo.persist() Function

The bo.persist() function can be conveniently used instead of bo.insert() or bo.update().

CaseMaster will decide which action to take based on the persist status; bo.insert() when the status is NEW and bo.update() when the status is CLEAN.

Property Persist Status

Each property also has a persist status (sometimes incorrectly called the attribute persist status rather than the property persist status).

The values are:

  • attrPersistStatus.New : The BO has been created and the property has not been assigned a value
  • attrPersistStatus.Loaded : The property has been assigned a value by loading it from the database
  • attrPersistStatus.Set : The property has been assigned a value (other than loading it from the database)
  • attrPersistStatus.Reset : The property has been assigned its' default value using bo.reset()

Using the Persist Status

You can use the bo.attrPersistStatus() to get the persist status of a property.

if eq( bo.attrPersistStatus( [_me], 'id' ), attrPersistStatus.New )
    // Stuff happens here when the PK has not been set
end-if

<End of document>