Object saved to variable throws RecordInvalid for data_option


  • Used Zammad version: 5.0
  • Used Zammad installation type: (source, package, docker-compose, …) package
  • Operating system: Ubuntu 18.04
  • Browser + version: Firefox/Chrome newest on both

Expected behavior:

  • creating an object and saving it to a variable ( object1 = ObjectManager::Attribute.create ) and setting all necessary paramaters ( object1.screens, object.data_option…) should generated a new Object after using object.save!

Actual behavior:

  • using a variable throws an ActiveRecord::RecordInvalid error because object1.data_option = { :type => “text”, :maxlength => 120, :null => true } both :type and :maxlength are allegedly not set.

Steps to reproduce the behavior:

  1. object1 = ObjectManager::Attribute.create
  2. Set parameters (object1.data_options, object1.screens etc)
  3. using object1.save! throws the error mentioned before

If you don’t use a variable and just do ObjectManager::Attribute.create(data_options: …).save! it works just fine. Also if you duplicate an existing Object to a variable and save that variable it works fine.

Dunno if that is intended and I’m just not seeing it.

Also e.g if you create a User Object via console it doesn’t get added to the user table within the postgres Database. Even after Cache.clear und restarting zammad I still have to add the new User Objects manually as a new column in the user table.

Sorry but I can’t really follow what you’re trying to do with the supplied information.
What I can see from what you’ve wrote that both approaches don’t make too much sense in my opinion.

If you want to write information of the created object into a variable that technically is possible, but requires you to create the object in one step and not several.

Also create combined with save at the end makes technically no sense at all.
You may want to stick to using the UI do add objects to rule out human error.

Please don’t get me wrong, I’m just trying to keep your instance in a working state here.