Package error when adding new attribute

Hello everyone,

I am currently trying to implement a new custom package for our company. In this package, we would like to add a new field “calendar” for Organizations, that would target to the calendar object.

So I added the below code:

ObjectManager::Attribute.add(
        object:      'Organization',
        name:        'calendar',
        display:     'Open hours calendar',
        data_type:   'select',
        data_option: {
            relation: 'Calendar',
            relation_condition: { access: 'full' },
            customsort: 'on',
            default: '',
            belongs_to: 'calendar',
            note: 'Choose here what open hours calendar should be applied for this company.',
            # nulloption:               true,
            # multiple:                 false,
            null:                     true,
            translate:                true,
        },
        editable:    true,
        active:      true,
        screens:     {
            view: {
                'ticket.customer' => {
                shown: false
                },
                'ticket.agent' =>  {
                shown: true
                },
                'admin.organization' =>  {
                shown: true
                },
                    },
            create: {
                'ticket.agent' =>  {
                shown: true,
                required: false
                },
                'admin.organization' =>  {
                shown: true,
                required: false
                }
            },
            edit: {
                'ticket.agent' =>  {
                shown: true,
                required: false
                },
                'admin.organization' =>  {
                shown: true,
                required: false
                }
            }
        },
        to_create:   false,
        to_migrate:  false,
        to_delete:   false,
        position:    1425,
        created_by_id:  1,
        updated_by_id:  1
    )

It seems to be working correctly: the field actually appears in the formular with a drop-down list corresponding to the calendar list.
However, we cannot save the Organization form anymore: when clicking on the “send” button, nothing happens.

To try and find out the origin of this error, I had a look at the Firefox console, and I got the following message:

App.i(error)                   | 
Object { _core_workflow: {…} }
application-6d0d7e19c7a28b742274f927c2a4d0648cd49d7adb1bfdb49fb4b4e3e02ebb99.js:23:21182
    _log http://172.19.0.10:8080/assets/application-6d0d7e19c7a28b742274f927c2a4d0648cd49d7adb1bfdb49fb4b4e3e02ebb99.js:23
    log http://172.19.0.10:8080/assets/application-6d0d7e19c7a28b742274f927c2a4d0648cd49d7adb1bfdb49fb4b4e3e02ebb99.js:23
    log http://172.19.0.10:8080/assets/application-6d0d7e19c7a28b742274f927c2a4d0648cd49d7adb1bfdb49fb4b4e3e02ebb99.js:23
    onSubmit http://172.19.0.10:8080/assets/application-6d0d7e19c7a28b742274f927c2a4d0648cd49d7adb1bfdb49fb4b4e3e02ebb99.js:29
    submit http://172.19.0.10:8080/assets/application-6d0d7e19c7a28b742274f927c2a4d0648cd49d7adb1bfdb49fb4b4e3e02ebb99.js:28
    t http://172.19.0.10:8080/assets/application-6d0d7e19c7a28b742274f927c2a4d0648cd49d7adb1bfdb49fb4b4e3e02ebb99.js:28
    s http://172.19.0.10:8080/assets/application-6d0d7e19c7a28b742274f927c2a4d0648cd49d7adb1bfdb49fb4b4e3e02ebb99.js:9
    dispatch http://172.19.0.10:8080/assets/application-6d0d7e19c7a28b742274f927c2a4d0648cd49d7adb1bfdb49fb4b4e3e02ebb99.js:2
    handle http://172.19.0.10:8080/assets/application-6d0d7e19c7a28b742274f927c2a4d0648cd49d7adb1bfdb49fb4b4e3e02ebb99.js:2

I am unsure on how I can get out of this and make the formular save correctly. Is there anything I missed in the addition of this attribute?

Any help to debug this would be greatly appreciated.

Thank you all.

Can you share the errors of your /opt/zammad/log/development.log ?

cat log/development.log | grep ERROR -A10

If I needed to take a guess then I think an attribute module for core workflow is missing. It looks like this:

You can easily copy and paste it and replace it with the Calendar class, and it might already work.

E.g.:

app/models/core_workflow/attributes/calendar.rb

class CoreWorkflow::Attributes::Calendar < CoreWorkflow::Attributes::Base
  def values
    @values ||= Calendar.all.pluck(:id)
  end
end
1 Like

Hello @rolfschmidt ,

Thank you so much for taking time to answer me. I have tried your suggestion, and you were right, it has solved the issue, that’s great!

I don’t have the file you told about, only production.log which is nearly empty. I will try and have a look on what I missed to make it appear.

Again, thank you for your time and precious inputs. It really helped me out!

1 Like