This problem is not related to the field. I tried checking another field (checkbox), that gave me the same problem. The other field I checked was not a custom field. The problem occurs when I use 'has changed' or 'has changed to' in a workflow task condition on a checkbos. When I switch off the condition evaluation or change the condition to 'exists', or 'is', it works. The condition serialization in the database is:
O:11:"VTEmailTask":20:{s:18:"executeImmediately";b:0;s:15:"attachmentsinfo";a:0:{}s:9:"dzattinfo";a:0:{}s:10:"workflowId";s:3:"112";s:7:"summary";s:69:"Verstuur e-mail naar Franka als order klaar is om ingepland te worden";s:6:"active";b:1;s:7:"trigger";N;s:8:"fromname";s:0:"";s:9:"fromemail";s:20:"crm@cbx-nederland.nl";s:7:"replyto";s:20:"crm@cbx-nederland.nl";s:7:"subject";s:53:"Order $salesorder_no is klaar om ingepland te worden";s:7:"content";s:188:"<p>Order $salesorder_no bij $(account_id : (Accounts) accountname) is klaar om ingepland te worden. Bekijk de order <a href="$(general : (__VtigerMeta__) crmdetailviewurl)">hier</a>.</p>
";s:9:"recepient";s:22:"guido@cbx-nederland.nl";s:7:"emailcc";s:0:"";s:8:"emailbcc";s:0:"";s:4:"test";s:144:"[{"fieldname":"so_goodsreceived","operation":"has changed to","value":"true:boolean","valuetype":"rawtext","joincondition":"and","groupid":"0"}]";s:2:"id";i:147;s:13:"attfieldnames";s:0:"";s:13:"attachmentids";s:0:"";s:10:"reevaluate";i:1;}
I tried turning on the background log, but that gave me a lot of information. Been browsing for some time but I don't know what to look for.
I did the following: in data/VTEntityDelta I added some log calls:
PHP Code:
public function hasChanged($moduleName, $recordId, $fieldName, $fieldValue = null) {
global $log;
$log->debug("DELTA");
$log->debug($moduleName);
$log->debug($recordId);
$log->debug($fieldName);
$log->debug($fieldValue);
if (empty(self::$oldEntity[$moduleName][$recordId])) {
return false;
}
@$fieldDelta = self::$entityDelta[$moduleName][$recordId][$fieldName]; // we know this will be empty sometimes, so we ignore the error
$result = $fieldDelta['oldValue'] != $fieldDelta['currentValue'];
$log->debug("DELTA2");
$log->debug($fieldDelta);
$log->debug($result);
if ($fieldValue !== null) {
$result = $result && ($fieldDelta['currentValue'] === $fieldValue);
}
return $result;
}
Then I checked the log for the specific field I'm editing. I see a lot of checkboxes where both my "DELTA" and "DELTA2" searchterm are showing:
Code:
2018-07-18T10:39:16+00:00 DEBUG index DELTA
2018-07-18T10:39:16+00:00 DEBUG index SalesOrder
2018-07-18T10:39:16+00:00 DEBUG index 115825
2018-07-18T10:39:16+00:00 DEBUG index send_to_workshop
2018-07-18T10:39:16+00:00 DEBUG index 1
2018-07-18T10:39:16+00:00 DEBUG index DELTA2
2018-07-18T10:39:16+00:00 DEBUG index
2018-07-18T10:39:16+00:00 DEBUG index
2018-07-18T10:39:16+00:00 DEBUG index
But on the field I'm checking, I see:
Code:
2018-07-18T10:39:21+00:00 DEBUG VT DELTA
2018-07-18T10:39:21+00:00 DEBUG VT SalesOrder
2018-07-18T10:39:21+00:00 DEBUG VT 115825
2018-07-18T10:39:21+00:00 DEBUG VT so_goodsreceived
2018-07-18T10:39:21+00:00 DEBUG VT 1
And there is no "DELTA2". I think for some reason the method is failing for these fields. Not sure why yet.
UPDATE
I see: 'self::$oldEntity' is empty, while for other fields it is set to the entity object. The function is designed to return false in that case, so the task will never trigger. But why is my entity object empty?