tag:help-archives.hannonhill.com,2010-02-09:/discussions/web-services/1576-setting-selected-items-in-a-multi-select-box-in-a-data-definitionCascade CMS: Discussion 2018-10-18T20:37:49Ztag:help-archives.hannonhill.com,2010-02-09:Comment/390716762016-02-02T15:24:36Z2016-02-02T15:24:36ZSetting selected items in a multi-select box in a Data Definition<div><p>We have a Page with a Data Definition defined as;</p>
<pre>
<code> <system-data-structure definition-path="Event">
<eventname>Winter Event</eventname>
<startdate>01-06-2016</startdate>
<enddate>01-27-2016</enddate>
<timestring>all day</timestring>
<category>
<value>Festive</value>
<value>Holidays</value>
</category>
<summary>Summary text</summary>
<details>Details text</details>
</system-data-structure></code>
</pre>
<p>The element is a multi-select list in the DD. I'm setting the
elements of the DD through the Web Service (.net client),
essentially creating a new Event Page. I'm struggling trying to set
more than one category on an Event.</p>
<p>Setting one is easy enough:</p>
<pre>
<code> structureddatanode cats = new structureddatanode();
cats.type = structureddatatype.text;
cats.identifier = "category";
cats.text = "Faculty";</code>
</pre>
<p>When the page asset is created an I examine the Event DD I see
the "Faculty" item selected in the multi-select list.</p>
<p>I thought if I created a structurednode array for the categories
it would set more than 1 value in the category list:</p>
<pre>
<code> structureddatanode cats = new structureddatanode();
cats.type = structureddatatype.text;
cats.identifier = "category";
String str = "Faculty|Festive";
var catlist = new List<structureddatanode>();
foreach (string s in str.Split(new char[] { '|' }))
{
structureddatanode category = new structureddatanode();
category.type = structureddatatype.text;
category.text = s;
catlist.Add(category);
}
cats.structuredDataNodes = catlist.ToArray();</code>
</pre>
<p>but this throws an exception:</p>
<pre>
<code> System.Web.Services.Protocols.SoapException: Validation error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'text'. One of '{"http://www.hannonhill.com/ws/ns/AssetOperationService":identifier}' is expected.; nested exception is:
java.lang.Exception: Validation error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'text'. One of '{"http://www.hannonhill.com/ws/ns/AssetOperationService":identifier}' is expected.</code>
</pre>
<p>Thinking about it it's not really a structured node of
categories, it's one element with multiple elements. How do I pass
multiple category strings through the web service in order to set
multiple items in the multi-select list of the DD? Anyone have a
working example? PHP would be fine, I can translate it into
.net.</p>
<p>Thanks.</p></div>sandertag:help-archives.hannonhill.com,2010-02-09:Comment/390716762016-02-02T17:49:53Z2016-02-02T17:49:53ZSetting selected items in a multi-select box in a Data Definition<div><p>I used the web service to retrieve one of the Pages with an
Event DD that already had multiple categories selected. In Fiddler
I took a look at the response from Cascade and found the Category
structured node and how it describes it's selected items:
::CONTENT-XML-SELECTOR::Festive::CONTENT-XML-SELECTOR::Holidays.
Maybe that's how I can set the selected fields, passing a similar
string when adding the Asset...</p>
<p>-</p>
<p>category</p>
<p>false</p>
<p>
::CONTENT-XML-SELECTOR::Festive::CONTENT-XML-SELECTOR::Holidays</p>
<p>text</p></div>sandertag:help-archives.hannonhill.com,2010-02-09:Comment/390716762016-02-02T17:56:28Z2016-02-02T17:56:28ZSetting selected items in a multi-select box in a Data Definition<div><p>Ok that worked. If I set the text on the structured node to the
string as described above then I get multiple items selected in the
select box.</p>
<pre>
<code> structureddatanode cats = new structureddatanode();
cats.type = structureddatatype.text;
cats.identifier = "category";
cats.text = "::CONTENT-XML-SELECTOR::Festive::CONTENT-XML-SELECTOR::Holidays";</code>
</pre>
<p>I will close the discussion, maybe it will help someone
else.</p></div>sander