<?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: How to programatically populate Complex Multivalued Fields ? in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-programatically-populate-complex-multivalued-fields/m-p/321726#M8727</link>
    <description>&lt;P&gt;Great news, you are welcome!&lt;/P&gt;</description>
    <pubDate>Sun, 02 Dec 2012 14:09:09 GMT</pubDate>
    <dc:creator>Aykut_Açikel</dc:creator>
    <dc:date>2012-12-02T14:09:09Z</dc:date>
    <item>
      <title>How to programatically populate Complex Multivalued Fields ?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-programatically-populate-complex-multivalued-fields/m-p/321723#M8724</link>
      <description>&lt;P&gt;I want to programatically populate Complex Multivalued Fields using Nuxeo Coresession object.
How do we access the subfield in the below case?&lt;/P&gt;
&lt;P&gt;Questions
Question1
Answer1&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;  Question2
  Answer2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Nov 2012 22:18:19 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/how-to-programatically-populate-complex-multivalued-fields/m-p/321723#M8724</guid>
      <dc:creator>Ansel_Andrew</dc:creator>
      <dc:date>2012-11-29T22:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to programatically populate Complex Multivalued Fields ?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-programatically-populate-complex-multivalued-fields/m-p/321724#M8725</link>
      <description>&lt;P&gt;I hope this will answer your question.
Let's say you have this in your schema (.xsd) :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;xs:element name="questions" type="nxs:questions" /&amp;gt;

&amp;lt;xs:complexType name="question"&amp;gt;
  &amp;lt;xs:sequence&amp;gt;
      &amp;lt;xs:element name="label" type="xs:string" /&amp;gt;
      &amp;lt;xs:element name="answer" type="xs:string" /&amp;gt;
  &amp;lt;/xs:sequence&amp;gt;
&amp;lt;/xs:complexType&amp;gt;

&amp;lt;xs:complexType name="questions"&amp;gt;
  &amp;lt;xs:sequence&amp;gt;
      &amp;lt;xs:element name="item" type="nxs:questions" minOccurs="0" maxOccurs="unbounded" /&amp;gt;
  &amp;lt;/xs:sequence&amp;gt;
&amp;lt;/xs:complexType&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In your code, you can do this :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;DocumentModel dm = ...;

 // get the list of complex values
List&amp;lt;Map&amp;lt;String, String&amp;gt;&amp;gt; questions = (List&amp;lt;Map&amp;lt;String, String&amp;gt;&amp;gt;)dm.getProperty("yourschema", "questions");
// you could get the subfields like that 
String question1 = questions.get(0).get("label");
String answer1 = questions.get(0).get("answer");

// add a new question
Map&amp;lt;String, String&amp;gt; newQuestion = new HashMap&amp;lt;String, String&amp;gt;();
newQuestion.put("label", "what is your question?");
newQuestion.put("answer", "my answer is that");
questions.add(newQuestion);

// update your document
dm.setProperty("yourschema", "questions", questions); // added
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But as you can see, it's kinda boring to manipulate list of maps.. So you should also use the Nuxeo document adapters to encapsulate all this code in one simple method..&lt;/P&gt;
&lt;P&gt;Let me know if you need more info on adapters.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2012 17:28:07 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/how-to-programatically-populate-complex-multivalued-fields/m-p/321724#M8725</guid>
      <dc:creator>Aykut_Açikel</dc:creator>
      <dc:date>2012-11-30T17:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to programatically populate Complex Multivalued Fields ?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-programatically-populate-complex-multivalued-fields/m-p/321725#M8726</link>
      <description>&lt;P&gt;Thanks a lot, have been searching for a solution for quite a while now. I integrated your code without any major modifications and it worked perfectly&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2012 20:59:58 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/how-to-programatically-populate-complex-multivalued-fields/m-p/321725#M8726</guid>
      <dc:creator>Ansel_Andrew</dc:creator>
      <dc:date>2012-11-30T20:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to programatically populate Complex Multivalued Fields ?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-programatically-populate-complex-multivalued-fields/m-p/321726#M8727</link>
      <description>&lt;P&gt;Great news, you are welcome!&lt;/P&gt;</description>
      <pubDate>Sun, 02 Dec 2012 14:09:09 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/how-to-programatically-populate-complex-multivalued-fields/m-p/321726#M8727</guid>
      <dc:creator>Aykut_Açikel</dc:creator>
      <dc:date>2012-12-02T14:09:09Z</dc:date>
    </item>
  </channel>
</rss>

