How to add a "vocabulary" field to the nuxeo user profile?

Hello everyone, I am currently trying to add a new attribute of type “vocabulary” to the user profile. I followed the following documentation: # HOWTO: Add New Fields to the User Profile or Group Profile, for a field of type string everything is fine. I was able to make it work, but on the other hand when I changed the type of the new field to be a “vocabulary” instead of string, I encountered an error, in fact, the “nuxeo-directory-suggestion” component displays the vocabulary identifier instead of the label. Here is my code:

<!-- nuxeo-edit-user.html -->
<!-- edit new community field -->
...
<nuxeo-directory-suggestion label="[[i18n('editUser.community')]]"
                            directory-name="VOC_Community"
                            min-chars="0"
                            value="{{user.community}}" name="community" required>
</nuxeo-directory-suggestion>
...
<!-- nuxeo-view-user.html -->
<!-- view new community field -->
...
      <div class="layout vertical flex">
        <nuxeo-directory-suggestion label="[[i18n('viewUser.community')]]"
                 value="[[user.properties.community]]" readonly="true"
                 min-chars="0"  directory-name="VOC_Community"
                 name="community">
        </nuxeo-directory-suggestion>
      </div>
...

I looked in the documentation and saw that you need to define a reference and an inverse reference, so I did, but it didn't work.

<component name="org.nuxeo.ecm.directory.storage">
  <require>org.nuxeo.ecm.platform.digestauth.config</require>
  <extension target="org.nuxeo.ecm.directory.GenericDirectory" point="directories">
  <directory name="userDirectory" extends="template-user">
      <schema>user</schema>
      <types>
        <type>system</type>
      </types>
      <idField>username</idField>
      <references>
        <reference field="community" directory="VOC_Community" name="user2community" source="userId" target="id"/>
      </references>
    </directory>
  </extension>
</component>

Please does anyone have an idea?

0 votes

1 answers

51 views

ANSWER



Hello,

To be displayed correctly, you need to use the following formatter: [[formatDirectory(document.properties.<XPATH>)]].

For the listing in edit mode, use formatter too (as https://github.com/nuxeo/nuxeo-studio-community-cookbook/tree/master/modules/nuxeo/document-suggestion-result-formatters)

Regards

0 votes