Konnte Konfigurationsform nicht laden (Undefined property)

Hallo zusammen,

ich habe mir ein Modul gemacht um Nachrichten an verschiedene Instanzen zu leiten.
Dieses funktioniert auch alles.

Nun habe ich zum Testen einen neuen Zweig erstellt und im Formular in der Liste ein neuen Feld (Checkbox) hinzugefügt. Ebenso im „GetConfigurationForm()“ im Modul.

Wenn ich die Instanz vom Modul neu anlege, kommt kein Fehler. Wenn ich jedoch das Modul aus dem alten Zweig schon hinzugefügt habe, und dann auf den neuen wechsel, bekomme ich eine Fehlermeldung.

<br />
<b>Notice</b>:  Undefined property: stdClass::$SendDefault in <b>/var/lib/symcon/modules/NotificationBoard/NotificationBoard/module.php</b> on line <b>169</b><br />
<br />
<b>Notice</b>:  Undefined property: stdClass::$SendDefault in <b>/var/lib/symcon/modules/NotificationBoard/NotificationBoard/module.php</b> on line <b>169</b><br />
<br />
<b>Notice</b>:  Undefined property: stdClass::$SendDefault in <b>/var/lib/symcon/modules/NotificationBoard/NotificationBoard/module.php</b> on line <b>169</b><br />
{"elements":[{"type":"List","name":"notificationWays","caption":"NotifyTypes","rowCount":10,"add":true,"delete":true,"sort":{"column":"NotificationWay","direction":"ascending"},"columns":[{"label":"InstanceID","name":"instanceID","width":"300px","add":0,"edit":{"type":"SelectInstance"}},{"label":"Notificationway","name":"NotificationWay","width":"300px","add":0,"edit":{"type":"ValidationTextBox"}},{"label":"Receiver","name":"Receiver","width":"auto","add":0,"edit":{"type":"ValidationTextBox"}},{"label":"Send default true","name":"SendDefault","width":"100px","add":1,"edit":{"type":"CheckBox"}}],"values":[{"NotificationWay":"E-Mail","Receiver":"deine@mail.de","SendDefault":null},{"NotificationWay":"WebFront SendNotification","Receiver":"","SendDefault":null},{"NotificationWay":"WebFront PopUp","Receiver":"","SendDefault":null}]},{"type":"ExpansionPanel","caption":"Create area for variables...","items":[{"type":"CheckBox","name":"CreateNotifyTypes","caption":"Create Variable for change Subjects (needed for HtmlBox or PopUp)"},{"type":"CheckBox","name":"CreateHtmlBox","caption":"Create Variable HtmlBox"},{"type":"CheckBox","name":"CreatePopUpModul","caption":"Create PopUp Module"}]},{"type":"ExpansionPanel","caption":"If checkbox active, then instances or variables become invisible","items":[{"type":"CheckBox","name":"NotifyTypesVisible","caption":"Variable NotifyTypes invisible (Attention! When using HtmlBox or PopUp this should be disabled)."},{"type":"CheckBox","name":"HtmlVisible","caption":"Variable Html Box invisible"},{"type":"CheckBox","name":"PopUpVisible","caption":"PopUp invisible"},{"type":"CheckBox","name":"InstanceVisible","caption":"Notification Instances invisible"}]},{"type":"ExpansionPanel","caption":"WebHook Control","items":[{"type":"ValidationTextBox","name":"Username","caption":"Username"},{"type":"PasswordTextBox","name":"Password","caption":"Password"}]}]} (Code: -32603)

Ich steh gerade auf dem Schlauch was ich falsch mache. Will die Instanz nach möglichkeit nicht neu anlegen und alles neu konfigurieren.

Hier die Form.json, es geht um die Spalte „SendDefault“.

{
  "elements": [	
    {
       "type": "List",
       "name": "notificationWays",
       "caption": "NotifyTypes",
       "rowCount": 10,
       "add": true,
       "delete": true,
       "sort": {
          "column": "NotificationWay",
          "direction": "ascending"
       },
       "columns": [
         {
            "label": "InstanceID",
            "name": "instanceID", 
            "width": "300px",
            "add": 0,
            "edit": {
               "type": "SelectInstance"
            }
         },
         {
            "label": "Notificationway",
            "name": "NotificationWay", 
            "width": "300px",
            "add": 0,
            "edit": {
               "type": "ValidationTextBox"
            }
          },
          {
            "label": "Receiver",
            "name": "Receiver", 
            "width": "auto",
            "add": 0,
            "edit": {
               "type": "ValidationTextBox"
            }
          },
          {
            "label": "Send default true",
            "name": "SendDefault", 
            "width": "100px",
            "add": 1,
            "edit": {
               "type": "CheckBox"
            }
          }
       ],
       "values": [
       ]
    },
    {
      "type": "ExpansionPanel",
      "caption": "Create area for variables...",
      "items": [
        {
          "type": "CheckBox",
          "name": "CreateNotifyTypes", 
          "caption": "Create Variable for change Subjects (needed for HtmlBox or PopUp)"
        },
        {
          "type": "CheckBox",
          "name": "CreateHtmlBox", 
          "caption": "Create Variable HtmlBox"
        },
        {
          "type": "CheckBox",
          "name": "CreatePopUpModul", 
          "caption": "Create PopUp Module"
        }
      ]
    },
    {
      "type": "ExpansionPanel",
      "caption": "If checkbox active, then instances or variables become invisible",
      "items": [
          {
            "type": "CheckBox",
            "name": "NotifyTypesVisible", 
            "caption": "Variable NotifyTypes invisible (Attention! When using HtmlBox or PopUp this should be disabled)."
          },
          {
            "type": "CheckBox",
            "name": "HtmlVisible", 
            "caption": "Variable Html Box invisible"
          },
          {
            "type": "CheckBox",
            "name": "PopUpVisible", 
            "caption": "PopUp invisible"
          },    
          {
            "type": "CheckBox",
            "name": "InstanceVisible", 
            "caption": "Notification Instances invisible"
          }
      ]
    },
    {
      "type": "ExpansionPanel",
      "caption": "WebHook Control",
      "items": [      
        { "type": "ValidationTextBox", "name": "Username", "caption": "Username" },
        { "type": "PasswordTextBox", "name": "Password", "caption": "Password" }
      ]
    }
  ]
}

Hier der Teil vom GetConfigurationForm(). Die Zeile 169 ist " „SendDefault“ => $treeRow->SendDefault".

        public function GetConfigurationForm()
        { 
          $data = json_decode(file_get_contents(__DIR__ . "/form.json"));
          
          //Only add default element if we do not have anything in persistence
          if($this->ReadPropertyString("notificationWays") == "") {			
            $data->elements[0]->values[] = Array(
              "instanceID"      => @IPS_GetInstanceListByModuleID ("{375EAF21-35EF-4BC4-83B3-C780FD8BD88A}")[0],
              "NotificationWay" => "E-Mail",
              "Receiver"        => "deine@mail.de",
              "SendDefault"     => false
            );
            $data->elements[0]->values[] = Array(
              "instanceID"      => @IPS_GetInstanceListByModuleID ("{3565B1F2-8F7B-4311-A4B6-1BF1D868F39E}")[0],
              "NotificationWay" => "WebFront SendNotification",
              "Receiver"        => "",
              "SendDefault"     => false
            );    
            $data->elements[0]->values[] = Array(
              "instanceID"      => @IPS_GetInstanceListByModuleID ("{3565B1F2-8F7B-4311-A4B6-1BF1D868F39E}")[0],
              "NotificationWay" => "WebFront PopUp",
              "Receiver"        => "",
              "SendDefault"     => false
            );                    
          } else {
            //Annotate existing elements
            $notificationWays = json_decode($this->ReadPropertyString("notificationWays"));

            foreach($notificationWays as $treeRow) {
              $data->elements[0]->values[] = Array(
                "NotificationWay" => $treeRow->NotificationWay,
                "Receiver"        => $treeRow->Receiver,
                "SendDefault"     => $treeRow->SendDefault
              );				
            }			
          }
          return json_encode($data);
        }

Auch ein MC_ReloadModule(35608,„NotificationBoard“) bringt nichts.
Vielleicht kann mich einer auf den richtigen Weg bringen.

Danke

Gruß
Oli

Ich vermute du hast die Spalte SendDefault erst später hinzugefügt. Damit haben alte Installationen des Moduls dieses Feld nicht und passen den erst beim ersten Übernehmen der Konfiguration via Konsole an. Du müsstest also prüfen, ob das Feld existiert und falls nicht auf den Standardwert gehen, sprich true.

Übrigens passen die Typen von „add“ in deiner Form abgesehen von instanceID nicht zu den verwendeten Feldern. Eine CheckBox ist Boolean, ValidationTextBox ist String. Das könnte zwar funktionieren, du bewegst dich aber auf dem Terrain von undefiniertem Verhalten, was jederzeit nicht mehr funktionieren könnte.

Super, vielen Dank. Das hat schon mal geklappt.

Kannst du mit hier auf die Spünge helfen?
Wüsste gerade nicht was du meinst und stehe auf dem Schlauch.

Gruß
Oli

Zum Beispiel:
Add ist hier integer (1) aber das Element CheckBox ist bool.
Michael

ah… jetzt hats klick gemacht.
Danke :slight_smile: