cancel
Showing results for 
Search instead for 
Did you mean: 

Its possible add new fields when create a new document?

ZETTA_INGENIERI
Champ in-the-making
Champ in-the-making

Hello,

I'm Java Developer, but I have a question, It's possible add new field when a user create a new document,? without nuxeo studio?

Thanks a lot

4 REPLIES 4

Yousuf_Nejati
Star Contributor
Star Contributor

Certainly!

Many configurations and customizations are possible without Nuxeo Studio. However, as it may be more enjoyable for the overzealous developer, it's definitely the more difficult route and requires a good understanding of the many extension points Nuxeo provides exactly for this purpose. Does that make sense?

There are a lot of steps necessary to do this. In general, you will need to:

  1. create a new schema with your field definition,
  2. override the default document type schema by simply adding your new schema to the list,
  3. add your new schema to your nuxeo project,
  4. create a new widget to hold the new field,
  5. add you new widget to your document's content view,
  6. package it all up in a Nuxeo compliant marketplace package, and
  7. deploy to your Nuxeo Platform instance.

For example, in order to add a new field to an existing Document Type's schema, you will need to:

  1. Create your new schema (my-new-doc-schema.xsd) with the desired field, for example:
<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:nxs="http://www.nuxeo.org/ecm/project/schemas/project1-testproject/companies" xmlns:nxsv="http://www.nuxeo.org/ecm/schemas/core/validation/" xmlns:ref="http://www.nuxeo.org/ecm/schemas/core/external-references/" targetNamespace="http://www.nuxeo.org/ecm/project/schemas/project1-testproject/companies">  
  <!-- helper XSD definitions for list types -->  
  <xs:complexType name="content"> 
    <xs:sequence> 
      <xs:element name="encoding" type="xs:string"/>  
      <xs:element name="mime-type" type="xs:string"/>  
      <xs:element name="data" type="xs:base64Binary"/>  
      <xs:element name="name" type="xs:string"/>  
      <xs:element name="length" type="xs:long"/>  
      <xs:element name="digest" type="xs:string"/> 
    </xs:sequence> 
  </xs:complexType>  
  <xs:simpleType name="stringList"> 
    <xs:list itemType="xs:string"/> 
  </xs:simpleType>  
  <xs:simpleType name="doubleList"> 
    <xs:list itemType="xs:double"/> 
  </xs:simpleType>  
  <xs:simpleType name="dateList"> 
    <xs:list itemType="xs:date"/> 
  </xs:simpleType>  
  <xs:simpleType name="integerList"> 
    <xs:list itemType="xs:integer"/> 
  </xs:simpleType>  
  <xs:simpleType name="booleanList"> 
    <xs:list itemType="xs:boolean"/> 
  </xs:simpleType>  
  <xs:complexType name="blobList"> 
    <xs:sequence> 
      <xs:element name="item" type="nxs:content" minOccurs="0" maxOccurs="unbounded"/> 
    </xs:sequence> 
  </xs:complexType>

  <!--References my custom companies vocabulary that was created, again, through extensions-->  
  <xs:element name="company">
    <xs:simpleType>
      <xs:restriction base="xs:string" ref:resolver="directoryResolver" ref:directory="companies"/>
    </xs:simpleType>
  </xs:element>

</xs:schema>
  1. Override the default schema of that document type (in this case Picture) through extension points, by adding for example:
<extension point="doctype" target="org.nuxeo.ecm.core.schema.TypeService">

    <facet name="Picture">
      <schema name="file"/>
      <schema name="picture"/>
      <schema name="image_metadata"/>
    </facet>

    <!-- deprecated since 7.1, here for compat -->
    <facet name="MultiviewPicture"/>

    <doctype extends="Document" name="Picture">
      <schema name="common"/>
      <schema name="uid"/>
      <schema name="dublincore"/>
      <!--Put your new schema here. Obviously you'd name it something better than this...-->
      <schema name="my-new-doc-schema"/>
      <facet name="Picture"/>
      <facet name="Versionable"/>
      <facet name="Publishable"/>
      <facet name="Commentable"/>
      <facet name="HasRelatedText"/>
    </doctype>

 </extension>

Make sure, when packaging your project, to declare 'override' in your extension point contribution header. You can learn more about building a Nuxeo compliant marketplace package here: https://doc.nuxeo.com/display/NXDOC/Understanding+Bundles+Deployment.

You can view the available extension points for your Nuxeo Platform release, here: http://explorer.nuxeo.com/nuxeo/site/distribution/Nuxeo%20DM-7.10/

Also, the Nuxeo Yeoman bootstrap generator may be of interest to you, found here: https://www.nuxeo.com/blog/the-new-way-to-bootstrap-your-application-with-nuxeo-generator/

Hopefully this is enough to get you started. If I were to provide you examples for each step, it would become more of a tutorial, and less of an answer. Am I right?

Of course, you can avoid all of this by registering your Nuxeo Platform with Nuxeo. Nuxeo Studio makes all of this 'easy-peezy-lemon-squeezy'.

-Yousuf

ZETTA_INGENIERI
Champ in-the-making
Champ in-the-making

Thanks a lot for your response. I'd like to add a new field (list type) with database information, for example, a contract type...

Thank u for your help

Hi Zetta,

Hi Yousuf

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.