Copied to clipboard

Flag this post as spam?

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

  • Paul Seal 519 posts 2844 karma points MVP 5x c-trib
    Jan 29, 2023 @ 13:01
    Paul Seal

    Creating a Block List Data Type Programmatically

    I am getting an error when trying to create a block list data type programmatically.

    {"ExceptionMessage":"Value of type BlockListConfiguration cannot be a configuration for editor Umbraco.BlockList, expecting. (Parameter 'value')"

    The issue is when I am trying to set the configuration.

    Please can you help me work out where I am going wrong?

    Here is my code:

    public void CreateDataType(string name)
        var newDataType = new DataType(
            new DataEditor(_dataValueEditorFactory)
                Alias = "Umbraco.BlockList"
            }, _configurationEditorJsonSerializer)
            Name = name,
            Configuration = new BlockListConfiguration
                Blocks = new[]
                    new BlockListConfiguration.BlockConfiguration
                        ContentElementTypeKey = new Guid("08e05150-1fe7-4810-96d2-cc0b9fd77a40"),
                        SettingsElementTypeKey = new Guid("55876948-ac8b-440f-bbca-19ac2bb18189"),
                        Label = "{{ !$title || $title == '' ? 'Test ' + $index : $title }}",
                        EditorSize = "medium",
                        ForceHideContentEditorInOverlay = false,
                        Stylesheet = "",
                        View = "",
                        IconColor = "#ffffff",
                        BackgroundColor = "#1b264f"
                MaxPropertyWidth = "100%",
                UseSingleBlockMode = false,
                UseLiveEditing = false,
                UseInlineEditingAsDefault = false,
                ValidationLimit = new BlockListConfiguration.NumberRange()
                    Min = 0,
                    Max = 10

    Kind regards


  • Sander Los 26 posts 158 karma points
    Jan 30, 2023 @ 06:04
    Sander Los

    Hi Paul,

    that is really weird. I get the same error when setting the configuration in the way you describe.

    I tried a couple of things and when I saved the DataType first (without the configuration) and set the configuration afterward (with the same values), the configuration is being set correctly. (below ugly/verbose code used for testing purposes)

    var config = new BlockListConfiguration{...}
    var testType = _dataTypeService.GetDataType(name);
    testType.Configuration = config;

    I hope someone else has some good insights on why it does not work when constructing it from scratch.

  • Paul Seal 519 posts 2844 karma points MVP 5x c-trib
    Jan 30, 2023 @ 07:22
    Paul Seal


    I got it working. My friends Anders and Callum helped me in the MVP slack group.

    I’ll update this post later with the solution.



Please Sign in or register to post replies

Write your reply to: