cancel
Showing results for 
Search instead for 
Did you mean: 

Custom vocabulary with custom columns

Rodri_
Star Contributor
Star Contributor

Hello,

I am trying to create a new vocabulary extracting the data from a table I have in my database, but I am having problems with operations like "Directory.Suggestion", and with methods like "formatDirectory()". The problem is my table doesn't have "ID" and "LABEL" columns. Instead of those columns, it has custom columns named "id_j" and "description", and I cannot change them (because other applications use them).

I have defined my directory:

<directory name="myVocabulary" extends="default-template-directory">
	<schema>tm_vocabulary</schema>
	<table>VOCABULARY_TABLE</table>
	<idField>id_j</idField>
</directory>

I have defined the "tm_vocabulary" schema:

<?xml version="1.0"?>

<xs:schema targetNamespace="http://www.nuxeo.org/ecm/schemas/vocabulary"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:element name="id_j" type="xs:string"/>
    <xs:element name="description" type="xs:string"/>

</xs:schema>

And I also have added the schema:

<schema name="tm_vocabulary" prefix="tmv" src="schema/directories/tm_vocabulary.xsd" />

Going to "Vocabularies" in the Nuxeo WebUI, I can see the vocabulary and its eantries without any problem. However, in one view, I have the following element:

<nuxeo-directory-suggestion 
    	role="widget" 
    	label="My property" 
    	name="myProperty"
    	directory-name="myVocabulary" 
    	value="{{document.properties.elem:myProperty}}" 
    	min-chars="0" required>
</nuxeo-directory-suggestion>

And this element is not working, because it is invoking "Directory.Suggestion", and this operation says "'label' column cannot be found". What can I do to use the nuxeo-directory-suggestion element with my custom vocabulary?

Thank you.

1 ACCEPTED ANSWER

Florent_Guillau
World-Class Innovator
World-Class Innovator

Vocabularies in Nuxeo require the standard id and label columns. The standard solution to this problem is to define a VIEW in your SQL database to have a new virtual table with the required columns that points to your existing table.

View answer in original post

2 REPLIES 2

Florent_Guillau
World-Class Innovator
World-Class Innovator

Vocabularies in Nuxeo require the standard id and label columns. The standard solution to this problem is to define a VIEW in your SQL database to have a new virtual table with the required columns that points to your existing table.

Definitely the best solution. Tested and working. Thank you!