<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Problems with Facets: schema property values of document not being saved in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/problems-with-facets-schema-property-values-of-document-not/m-p/324017#M11018</link>
    <description>&lt;P&gt;Nevermind, "Generic" is the correct widget to use... got it working now. Thanks for your help.&lt;/P&gt;</description>
    <pubDate>Wed, 08 Feb 2017 18:27:03 GMT</pubDate>
    <dc:creator>mathias_lin</dc:creator>
    <dc:date>2017-02-08T18:27:03Z</dc:date>
    <item>
      <title>Problems with Facets: schema property values of document not being saved</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/problems-with-facets-schema-property-values-of-document-not/m-p/324011#M11012</link>
      <description>&lt;P&gt;I am facing some problems and questions with facets.&lt;/P&gt;
&lt;H2&gt;Problem 1: Facet fields (assigned schema's fields) don't get saved:&lt;/H2&gt;
&lt;P&gt;I have defined a schema called 'InvoiceSchema' and a facet called 'InvoiceFacet' and assigned the schema to the facet, like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="type an image title"&gt;&lt;img src="https://connect.hyland.com/t5/image/serverpage/image-id/1916iF46C404EDA2AA757/image-size/large?v=v2&amp;amp;px=999" role="button" title="type an image title" alt="type an image title" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="type an image title"&gt;&lt;img src="https://connect.hyland.com/t5/image/serverpage/image-id/1917iF83E3EFCC70B6BE2/image-size/large?v=v2&amp;amp;px=999" role="button" title="type an image title" alt="type an image title" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I enabled the facet for the document type 'File'&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="type an image title"&gt;&lt;img src="https://connect.hyland.com/t5/image/serverpage/image-id/1919iF20FECA1F7C7C768/image-size/large?v=v2&amp;amp;px=999" role="button" title="type an image title" alt="type an image title" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;and I change the edit and view layout to display the fields:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="type an image title"&gt;&lt;img src="https://connect.hyland.com/t5/image/serverpage/image-id/1918iC530E39E6D963E72/image-size/large?v=v2&amp;amp;px=999" role="button" title="type an image title" alt="type an image title" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Back in the JSF UI and after the update, the fields get displayed in the view and edit layouts. However, when I edit the value, they don't get stored.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="type an image title"&gt;&lt;img src="https://connect.hyland.com/t5/image/serverpage/image-id/1920iE7AC4051672D6D3B/image-size/large?v=v2&amp;amp;px=999" role="button" title="type an image title" alt="type an image title" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This is the view layout after saving the document. The confirmation message tells me that saving was successful, and values that I enter in other fields get updated just fine. Only the fields of my InvoiceSchema don't get saved.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="type an image title"&gt;&lt;img src="https://connect.hyland.com/t5/image/serverpage/image-id/1922i4EAE5127755F6E3F/image-size/large?v=v2&amp;amp;px=999" role="button" title="type an image title" alt="type an image title" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;When I export the file as xml, I only see this in it:&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;&amp;lt;facet&amp;gt;InvoiceFacet&amp;lt;/facet&amp;gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;but I don't see the fields that I defined for my InvoiceSchema (like Amount, InvoiceDate, RecordId) anywhere in the xml.&lt;/P&gt;
&lt;P&gt;Interestingly, if I don't use a facet that has my schema assigned, but add the schema directly to the File type, the problem does not exist and the values get saved. Looks like a bug to me?! Unfortunately I don't have a Jira account yet in order to submit it.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="type an image title"&gt;&lt;img src="https://connect.hyland.com/t5/image/serverpage/image-id/1921i88E172E7172745EA/image-size/large?v=v2&amp;amp;px=999" role="button" title="type an image title" alt="type an image title" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;
&lt;H3&gt;Update after Betrand's reply:&lt;/H3&gt;
&lt;P&gt;Hello Bertrand,&lt;/P&gt;
&lt;P&gt;thanks for your reply.  I understood the explanation you gave above about the registry as well as the xml extension points. Not sure though where I am supposed to define the schema itself (in my case, the 'InvoiceSchema').&lt;/P&gt;
&lt;P&gt;Did I do it right via "Studio &amp;gt; Content Model &amp;gt; Schemas" or should I register the schema via "Studio &amp;gt; Settings &amp;gt; Registries &amp;gt; Document Schemas", or both. When I register the schema via the latter as well (additionally to having it defined under the Content Model &amp;gt; Schemas menu), then I get some validation errors like this:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://snag.gy/5jz3Qi.jpg" target="test_blank"&gt;https://snag.gy/5jz3Qi.jpg&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;saying "Invalid name 'InvoiceSchema' for a schema: this schema already exists in the default application". So I removed the schema from the registry again. (From what I understand, I shouldn't need to register the schema in the registry anyway, since what I define under "Content Model" should be known both by my local Nuxeo instance (since it's part of my package) as well as the Studio.)&lt;/P&gt;
&lt;P&gt;So, I assume it's sufficient to just define it under the "Studio &amp;gt; Content Model &amp;gt; Schemas":&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="type an image title"&gt;&lt;img src="https://connect.hyland.com/t5/image/serverpage/image-id/1923i5AECC47C3405D6FC/image-size/large?v=v2&amp;amp;px=999" role="button" title="type an image title" alt="type an image title" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I tried it out and deployed that package. But still the properties don't get stored when I save the document.&lt;/P&gt;
&lt;P&gt;Looking at my package jar that I deployed, the xml extension and the schema including the properties are all included.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="type an image title"&gt;&lt;img src="https://connect.hyland.com/t5/image/serverpage/image-id/1930i9115596EE80F4385/image-size/large?v=v2&amp;amp;px=999" role="button" title="type an image title" alt="type an image title" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Checking the log, I see this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;2017-01-30 18:19:59,277 WARN [http-bio-0.0.0.0-8080-exec-17] [org.nuxeo.ecm.platform.el.DocumentModelResolver] org.nuxeo.ecm.core.api.model.PropertyNotFoundException: InvoiceSchema:InvoiceDate 2017-01-30 18:19:59,277 WARN [http-bio-0.0.0.0-8080-exec-17] [org.nuxeo.ecm.platform.el.DocumentModelResolver] org.nuxeo.ecm.core.api.model.PropertyNotFoundException: InvoiceSchema:Amount 2017-01-30 18:19:59,278 WARN [http-bio-0.0.0.0-8080-exec-17] [org.nuxeo.ecm.platform.el.DocumentModelResolver] org.nuxeo.ecm.core.api.model.PropertyNotFoundException: InvoiceSchema:RecordId
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;
&lt;H2&gt;Problem 2: How can I define view layout and edit layout for documents with certain facets?&lt;/H2&gt;
&lt;P&gt;Let's say I have a facet that is not assigned to all documents (= not as described in problem 1), but only to some, for example when the facet gets assigned dynamically via an automation, and the facet has a schema with some additional property fields assigned. How can I show these fields in the view and edit layout based on whether the document has this facet or not? I cannot find this option in the Studio.
In Studio, I can only define the view and edit layouts fixed for a certain document type, but I cannot give any conditions, such as 'if the document has facet x applied'. How to solve this?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2017 17:15:52 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/problems-with-facets-schema-property-values-of-document-not/m-p/324011#M11012</guid>
      <dc:creator>mathias_lin</dc:creator>
      <dc:date>2017-01-26T17:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with Facets: schema property values of document not being saved</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/problems-with-facets-schema-property-values-of-document-not/m-p/324012#M11013</link>
      <description>&lt;P&gt;Hello Mathias,&lt;/P&gt;
&lt;P&gt;Problem #1:
To add a facet and use it in Studio, there are two things to do:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Add an XML extension so that Nuxeo Platform knows about it&lt;/LI&gt;
&lt;LI&gt;Declare it in the registries so that it becomes visible in Nuxeo Studio&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;You did step #2. That means Studio will behave as if the facet exists in Nuxeo Platform, which is why everything works smoothly until you deploy your config.
But as you are missing step #1, the facet doesn't actually exist in Nuxeo Platform!&lt;/P&gt;
&lt;P&gt;To fix this, in Nuxeo Studio you need to declare the facet in the Advanced Settings &amp;gt; XML Extensions menu (make sure to replace with the appropriate facet and schema values of course):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;!-- This makes my facet available in Nuxeo Platform, then I can declare it in the registries --&amp;gt;
&amp;lt;extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype"&amp;gt;
  &amp;lt;facet name="MyFacet"&amp;gt;
    &amp;lt;schema name="MySchema"/&amp;gt;
  &amp;lt;/facet&amp;gt;
&amp;lt;/extension&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The reason Nuxeo Studio does not create the corresponding extension automatically when declaring a facet in the registries is because it could be contributed from somewhere else: another bundle or Studio project for instance. However, an improvement could be to better inform users and / or offer to do it =&amp;gt; I'll create a ticket for that.&lt;/P&gt;
&lt;P&gt;Problem #2:&lt;/P&gt;
&lt;P&gt;In a layout, a widget's mode (edit, read only, hidden) can be changed depending on a custom condition. I may advise you to have a look at the documentation explaining &lt;A href="https://doc.nuxeo.com/nxdoc/how-to-control-the-display-mode-of-a-widget/"&gt;how to control the display mode of a widget&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;In your example, the condition to use should be something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;#{currentDocument.hasFacet('MyFacet') ? 'edit' : 'hidden'}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The currentDocument variable relates to a &lt;A href="http://community.nuxeo.com/api/nuxeo/latest/javadoc/org/nuxeo/ecm/core/api/DocumentModel.html"&gt;DocumentModel&lt;/A&gt; object, so you can easily add further conditions and not only check for the facet.&lt;/P&gt;
&lt;P&gt;-- edit --
Improvement ticket created: &lt;A href="https://jira.nuxeo.com/browse/NXS-3810" target="test_blank"&gt;https://jira.nuxeo.com/browse/NXS-3810&lt;/A&gt;
Thanks for the feedback! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2017 13:34:56 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/problems-with-facets-schema-property-values-of-document-not/m-p/324012#M11013</guid>
      <dc:creator>Bertrand_Chauvi</dc:creator>
      <dc:date>2017-01-30T13:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with Facets: schema property values of document not being saved</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/problems-with-facets-schema-property-values-of-document-not/m-p/324013#M11014</link>
      <description>&lt;P&gt;Hello Bertrand,&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2017 15:31:50 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/problems-with-facets-schema-property-values-of-document-not/m-p/324013#M11014</guid>
      <dc:creator>mathias_lin</dc:creator>
      <dc:date>2017-01-30T15:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with Facets: schema property values of document not being saved</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/problems-with-facets-schema-property-values-of-document-not/m-p/324014#M11015</link>
      <description>&lt;P&gt;[Bertrand Chauvin](https&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2017 18:43:38 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/problems-with-facets-schema-property-values-of-document-not/m-p/324014#M11015</guid>
      <dc:creator>mathias_lin</dc:creator>
      <dc:date>2017-01-30T18:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with Facets: schema property values of document not being saved</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/problems-with-facets-schema-property-values-of-document-not/m-p/324015#M11016</link>
      <description>&lt;P&gt;I spawned a new Nuxeo docker container and the problem with the properties of my custom facet not being saved is gone. Basically using the same project configuration from the Studio. Maybe something was broken with the initial instance.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 17:41:34 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/problems-with-facets-schema-property-values-of-document-not/m-p/324015#M11016</guid>
      <dc:creator>mathias_lin</dc:creator>
      <dc:date>2017-02-08T17:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with Facets: schema property values of document not being saved</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/problems-with-facets-schema-property-values-of-document-not/m-p/324016#M11017</link>
      <description>&lt;P&gt;[Bertrand Chauvin](https&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 18:22:17 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/problems-with-facets-schema-property-values-of-document-not/m-p/324016#M11017</guid>
      <dc:creator>mathias_lin</dc:creator>
      <dc:date>2017-02-08T18:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with Facets: schema property values of document not being saved</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/problems-with-facets-schema-property-values-of-document-not/m-p/324017#M11018</link>
      <description>&lt;P&gt;Nevermind, "Generic" is the correct widget to use... got it working now. Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 18:27:03 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/problems-with-facets-schema-property-values-of-document-not/m-p/324017#M11018</guid>
      <dc:creator>mathias_lin</dc:creator>
      <dc:date>2017-02-08T18:27:03Z</dc:date>
    </item>
  </channel>
</rss>

