Programmatically creating block list items, and sa...
# help-with-umbraco
l
I have a page in Umbraco 13, i'm trying to create a few block list items, then save this to the page. The page is being generated fine when i comment out the setValue for setting the block list item. I found a our.umbraco post from 2020, which pointed to https://github.com/umbraco/UmbracoDocs/blob/e64ec0e5b28b4e5a37b7865691621e45dd82701f/Getting-Started/Backoffice/Property-Editors/Built-in-Property-Editors/Block-List-Editor/index.md which is what i followed. Any docs / suggestions on how to get this working?
d
I have a small package that generates random content, also for blocklist. This here is the part that creates a blocklist value: https://github.com/Infocaster/ContentGenerator/blob/v13%2Fmain/ContentGenerator%2FGenerator%2FEnrichment%2FImplementations%2FBlocklistPropertyFiller.cs
l
Thats great, i have a block being created now, just working on adding some content within it, just working out how lines 20/21 works at https://github.com/Infocaster/ContentGenerator/blob/v13/main/ContentGenerator/Generator/Enrichment/Implementations/BlockFactory.cs#L20 Looks like I have to set the RawPropertyValues, which im setting but theyre not being saved as expected
Here is what I have,
Copy code
result.RawPropertyValues = new Dictionary<string, object?>()
{
    {"productName", "Test"}
};
Where
productName
is an alias on the block list item im adding, its saving the block, just not adding any properties.
So i had each of the properties i was trying to set as Labels, as i dont want them updated, as soon as i set them to textstrings they started to populate
d
Interesting
I would expect labels to work the same as textstring properties
l
As did I, they work when setting on a page, just not as block data, strange one, potentially a bug somewhere in core.
43 Views