Setting selected items in a multi-select box in a Data Definition

sander's Avatar

sander

02 Feb, 2016 03:24 PM

We have a Page with a Data Definition defined as;

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

The <category> 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 <value> on an Event.

Setting one is easy enough:

                structureddatanode cats = new structureddatanode();
                cats.type = structureddatatype.text;
                cats.identifier = "category";
                cats.text = "Faculty";

When the page asset is created an I examine the Event DD I see the "Faculty" item selected in the multi-select list.

I thought if I created a structurednode array for the categories it would set more than 1 value in the category list:

                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();

but this throws an exception:

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.

Thinking about it it's not really a structured node of categories, it's one <category> element with multiple <value> 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.

Thanks.

  1. 1 Posted by sander on 02 Feb, 2016 05:49 PM

    sander's Avatar

    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: <text>::CONTENT-XML-SELECTOR::Festive::CONTENT-XML-SELECTOR::Holidays</text>. Maybe that's how I can set the selected fields, passing a similar string when adding the Asset...

    -<structuredDataNode>

    <assetType xsi:nil="true"/>

    <blockId xsi:nil="true"/>

    <blockPath xsi:nil="true"/>

    <fileId xsi:nil="true"/>

    <filePath xsi:nil="true"/>

    <identifier>category</identifier>

    <pageId xsi:nil="true"/>

    <pagePath xsi:nil="true"/>

    <recycled>false</recycled>

    <structuredDataNodes xsi:nil="true"/>

    <symlinkId xsi:nil="true"/>

    <symlinkPath xsi:nil="true"/>

    <text>::CONTENT-XML-SELECTOR::Festive::CONTENT-XML-SELECTOR::Holidays</text>

    <type>text</type>

    </structuredDataNode>

  2. 2 Posted by sander on 02 Feb, 2016 05:56 PM

    sander's Avatar

    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.

                    structureddatanode cats = new structureddatanode();
                    cats.type = structureddatatype.text;
                    cats.identifier = "category";
                    cats.text = "::CONTENT-XML-SELECTOR::Festive::CONTENT-XML-SELECTOR::Holidays";

    I will close the discussion, maybe it will help someone else.

  3. sander closed this discussion on 02 Feb, 2016 05:56 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM