Skip to content

Instantly share code, notes, and snippets.

@joebordes
Created December 14, 2018 09:40
Show Gist options
  • Save joebordes/05477d8917d7b9a60e09f3536ab2ac13 to your computer and use it in GitHub Desktop.
Save joebordes/05477d8917d7b9a60e09f3536ab2ac13 to your computer and use it in GitHub Desktop.
Force events and workflow on records
<?php
// Turn on debugging level
$Vtiger_Utils_Log = true;
include_once 'vtlib/Vtiger/Module.php';
error_reporting(E_ALL);
ini_set('display_errors', 'on');
$usr = new Users();
$current_user = Users::getActiveAdminUser();
//Event triggering code
require_once 'include/events/include.inc';
global $adb, $log;
$module = 'Leads';
$em = new VTEventsManager($adb);
// Initialize Event trigger cache
$em->initTriggerCache();
$ents = $adb->pquery('select crmid from vtiger_crmentity where deleted=0 and setype=?', array($module));
while ($ent = $adb->fetch_array($ents)) {
$entityData = VTEntityData::fromEntityId($adb, $ent['crmid']);
// Event triggering code
// NOTE: has_changed conditions will NOT work
$em->triggerEvent('vtiger.entity.aftersave', $entityData);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment