Global hash functions - hdijkema/espocrm-hookedformulas GitHub Wiki

Global\Set

Global\Set(KEY, VALUE)

Stores the value globally for the given Formula Session. This is no permanent store! This can e.g. be used when a recalculation is triggered during 'afterSave' and we don't want to get into an endless save loop.

Example:

// For an entity Entity

begin:afterSave

  // If we get saved in OtherEntity during the recalculation process, 
  // we don't want to trigger another recalculation

  $key = string\concatenate('my-entity-guard-', id);
  ifThenElse(Global\IsSet($key),
     log('info', 'prevent recursion');
     ,
     Global\Set($key, true);
     record\recalculate('OtherEntity', 'year=', year);
     Global\UnSet($key);
  );
 
end:afterSave

Global\Get

VALUE = Global\Get(KEY)

Gets a previously stored value.

Global\IsSet

BOOL = Global\IsSet(KEY)

Returns true if the key was set.

Global\UnSet

Global\UsSet(KEY)

Clears the key in the global store.

Global\Set

Global\Set(KEY, VALUE)

Sets key to value.