/**
  * Returns the value of the field for the condition
  * For example: I want to check if age > 50, this function would return the 50
  *
  * @param object CRM_Civirules_TriggerData_TriggerData $triggerData
  * @return
  * @access protected
  * @abstract
  */
 protected function getFieldValue(CRM_Civirules_TriggerData_TriggerData $triggerData)
 {
     $entity = $this->conditionParams['entity'];
     $field = $this->conditionParams['field'];
     $data = $triggerData->getEntityData($entity);
     if (isset($data[$field])) {
         return $this->normalizeValue($data[$field]);
     }
     if (strpos($field, 'custom_') === 0) {
         $custom_field_id = str_replace("custom_", "", $field);
         try {
             $params['entityID'] = $data['id'];
             $params[$field] = 1;
             $values = CRM_Core_BAO_CustomValueTable::getValues($params);
             if (!empty($values[$field])) {
                 return $this->normalizeValue($values[$field]);
             } elseif (!empty($values['error_message'])) {
                 $custom_values = $triggerData->getCustomFieldValues($custom_field_id);
                 if (!empty($custom_values)) {
                     return $this->normalizeValue(reset($custom_values));
                 }
             }
         } catch (Exception $e) {
             //do nothing
         }
     }
     return null;
 }