Its possible add new fields when create a new document?

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

0 votes

2 answers

2996 views

ANSWER



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

0 votes



Hi Zetta,

Please be mindful of the separation between comments and answers. It's helpful to keep things organized. You can edit your answer, moving it to comments, effectively.

Best,

-Yousuf

08/19/2016

Hi Yousuf

Thank you

08/19/2016


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>

2) 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

0 votes