diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php
index e84b4b6a6d816bbe7d0683a92a4db449053ace36..a1788d5b45a8dfcaf726fc2876e3f31f265026fa 100644
--- a/include/class.dynamic_forms.php
+++ b/include/class.dynamic_forms.php
@@ -349,6 +349,9 @@ class TicketForm extends DynamicForm {
             return;
 
         $f = $answer->getField();
+        if (!$f->getFormId())
+            return;
+
         $name = $f->get('name') ?: ('field_'.$f->get('id'));
         $fields = sprintf('`%s`=', $name) . db_input(
             implode(',', $answer->getSearchKeys()));
@@ -470,6 +473,9 @@ class DynamicFormField extends VerySimpleModel {
 
     function getAnswer() { return $this->answer; }
 
+    function getForm() { return $this->form; }
+    function getFormId() { return $this->form_id; }
+
     /**
      * setConfiguration
      *