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

0 votes

1 answers

2125 views

ANSWER



Hello

Here is what has to be done to update the user profile.

Studio side

  1. 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.

  2. add the fields you want

  3. head over to CONFIGURATION / Resources / Schemas

  4. import the XSD file

  5. go to CONFIGURATION / Advanced Settings / XML Extensions

  6. 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>
    
  7. 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:

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
1 votes



a c
Thank you so much for your answer. I thought I could just override directories the same way schemas are overriden, with a override=&quot;true&quot; 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!
12/06/2019