Dynamic creation of custom Elements

Hello,
I want to achieve that modeling Elements can dynamically be added to the palette. With static Elements I got it working an I am wondering how to adapt this to dynamically adding. I tried to create and array with objects of the elements but this doesnt work with the create Method. Basically I tried like this:

addModelingElement({commit}, element){
            let fieldName = element.taskType.toLowerCase();
            const newElement = {
                'create.painPoint': {
                    group: 'activity',
                    title: 'Create '+ fieldName,
                    imageUrl: element.icon,
                    action: {
                      dragstart: () => startCreate(element.taskType.toUpperCase()),
                      click: () =>  startCreate(element.taskType.toUpperCase())
                    }
                  }
            }
            commit('ADD_MODELING_ELEMENT', newElement);
        }

But the Elements dont get added to the Palette. Maybe someone did the same thing and can help me out.

Thank you very much

We need more context to be able to help you. What is commit doing? How are the elements supposed to be added?