Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Raluca Dumitru 33 posts 174 karma points
    Sep 30, 2020 @ 14:41
    Raluca Dumitru
    0

    Error when setting the values for a checkbox list property

    Hi all

    I want to set the values for a checkbox list page property in my controller.

    This is my code example:

                        newOrg.SetValue("orgTypes", "3, 6, 9");
    
                        contentService.Save(newOrg);   
    

    I am getting this error when I try to open the new created page in the backofficeenter image description here

    I am using this example, but I am not sure this is the best approach. Any help is appreciated.

    Thank you

  • Raluca Dumitru 33 posts 174 karma points
    Oct 01, 2020 @ 15:07
    Raluca Dumitru
    102

    Finally I've found a way to do this!!

    I have manually created a 'newOrg' and saved it with the following checkbox list values ticked : type1, type2, type3.

    Then I went into the database and checked how the value for my checkbox list is stored. This is the format:

    "orgTypes":[{"culture":"","seg":"","val":"[\"type1\",\"type2\",\"type3\"]"}]

    So I've modified my code to:

    newOrg.SetValue("orgTypes", "[\"type1\",\"type2\",\"type3\"]");
    

    Thinking about it, I can probably use the database information for more complex data types as well, like nested properties.

    Hope this will help someone else someday :)

  • TomDS 8 posts 99 karma points
    Mar 30, 2022 @ 15:04
    TomDS
    1

    This helped me out a couple of years down the line,

    Thanks Raluca.

Please Sign in or register to post replies

Write your reply to:

Draft