johnkhigginson
03/13/2024, 8:46 PMif (content.HasProperty("locations"))
{
var locations = content.GetValue<BlockListModel>("locations");
(or)
var locations = content.GetValue<IEnumerable<BlockListItem>>("locations");
...
}
If I pull the value as a string or dynamic object, it will show as:
{
"layout": {
"Umbraco.BlockList": [
{
"contentUdi": "umb://element/74437d1928534a9287430056e140b99b"
},
{
"contentUdi": "umb://element/382ddba6783948b28696798b3b6dad16"
}
]
},
"contentData": [
{
"contentTypeKey": "0285ad7f-763f-4bc5-80be-45f85f8a39e6",
"udi": "umb://element/74437d1928534a9287430056e140b99b",
"city": "Colville",
"stateA": "[\"WA\"]",
"name": "Colville Toyota"
},
{
"contentTypeKey": "0285ad7f-763f-4bc5-80be-45f85f8a39e6",
"udi": "umb://element/382ddba6783948b28696798b3b6dad16",
"stateA": "[\"OR\"]",
"name": "Coos Bay Toyota",
"city": "Coos Bay"
}
],
"settingsData": []
}
In converting to the BlockListModel, it has to be erroring causing it to return null; right? I need to pull the values this way because I am using those values to calculate other properties and then save that property to the document.
Anyone running into this or have a solution? Is this enough info? I feel like I've tried quite a bit without success.Jemayn
03/14/2024, 8:03 AMRavi
03/14/2024, 11:35 AMjohnkhigginson
03/14/2024, 2:35 PMContentSavingNotification
. (var content in notification.SavedEntities.Where...
)Jemayn
03/14/2024, 2:43 PMjohnkhigginson
03/14/2024, 2:45 PMcontent.setValue("locations", json)
?Jemayn
03/14/2024, 2:48 PMjohnkhigginson
03/14/2024, 2:52 PMA hub and casual space for you to interact with fellow community members and learn more about Umbraco!
Powered by