Adding colums to the default user schema
Hello community, I'm trying to add more fields to the user creation form. I've been following the tutorial at https://doc.nuxeo.com/nxdoc/how-to-add-new-fields-to-the-user-profile-or-group-profile/ Where it shows how to override the default user schema. I followed suit and added my custom user schema as well as the references contribution as shown. I also modified the edit user layout to add my custom fields (they are simple nuxeo-inputs with the new user fields as values).
However whenever I create or edit an user, those fields are never persisted; looking at the database those fields/columns are also missing. I checked the server logs as well and found that the schema manager actually marks my custom schema as registered.
Is there another configuration that s missing? I'd appreciate any help
Hello
Here is what has to be done to update the user profile.
Studio side
use the XSD file (for example my_custom_user.xsd) from the user schema (see documentation above) as a basis and keep the namespace, etc.
add the fields you want
head over to CONFIGURATION / Resources / Schemas
import the XSD file
go to CONFIGURATION / Advanced Settings / XML Extensions
add the following configuration:
<extension point="schema" target="org.nuxeo.ecm.core.schema.TypeService"> <!-- override default user schema --> <schema name="user" override="true" src="data/schemas/my_custom_user.xsd"/> </extension>
to double-check those steps were effective, you can go check into your database that the fields are indeed present in the users table after synching your project server-side and restarting Nuxeo.
Web UI side
After checking the code, you will need to:
- override the nuxeo-edit-user.html element by writing a custom element:
https://github.com/nuxeo/nuxeo-ui-elements/blob/maintenance-2.4.x/nuxeo-user-group-management/nuxeo-edit-user.html
adding the field(s) you just added to the schema - override the nuxeo-create-user element
https://github.com/nuxeo/nuxeo-ui-elements/blob/maintenance-2.4.x/nuxeo-user-group-management/nuxeo-create-user.html
so that it uses the custom element based on nuxeo-edit-user - override the nuxeo-user-group-management element
https://github.com/nuxeo/nuxeo-ui-elements/blob/maintenance-2.4.x/nuxeo-user-group-management.html
so that it uses the custom element based on nuxeo-create-user - override the nuxeo-user-group-management-page
https://github.com/nuxeo/nuxeo-web-ui/blob/10.10/elements/nuxeo-admin/nuxeo-user-group-management-page.html
so that it uses the custom element based on nuxeo-user-group-management - then you will be able to override the ADMINISTRATION_PAGES slot in nuxeo–custom-bundle.html
so that it uses your overriden version of the nuxeo-user-group-management-page element.
(in Studio you can find it in Designer / RESOURCES / UI)
For reference the original slot definition is defined here:
https://github.com/nuxeo/nuxeo-web-ui/blob/10.10/elements/nuxeo-web-ui-bundle.html#L27
override="true"
property in the directory definition but that wasn't the case. In the end I had everything as you described, but the error was in the directory references. The only way it worked was by defining a customUserDirectory and updating the references in the groupDirectory!