Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have a nested content list (meetingItemDayTimes) inside nested content list (meetingDatesAvailable).
I want to set a checkbox to true on the each time item. But I can't for the life of me get it to work.
The structure is like:
My code is this:
var mainpage = contentService.GetById(1057); var dateItems = Umbraco.Content(parentNode).Value<IEnumerable<IPublishedElement>>("meetingDatesAvailable"); var ncItems = new JArray(); var ncDateItems = new JArray(); var ncTimeItems = new JArray(); if (dateItems != null && dateItems.Any()) { foreach (var dateItem in dateItems) { var ncDateItem = new JObject(); ncDateItem.Add("key", dateItem.Key.ToString()); ncDateItem.Add("ncContentTypeAlias", dateItem.ContentType.Alias); ncDateItem.Add("meetingItemDay", dateItem.Value<string>("meetingItemDay", fallback: Fallback.ToDefaultValue, defaultValue: null)); var times = dateItem.Value<IEnumerable<IPublishedElement>>("meetingItemDayTimes"); foreach (var time in times) { var ncTimeItem = new JObject(); if (time.Key.ToString() == itemKey) { ncTimeItem.Add("meetingdateTimeItemUnavailable", true); } else { ncTimeItem.Add("meetingdateTimeItemUnavailable", time.Value<bool>("meetingdateTimeItemUnavailable", fallback: Fallback.ToDefaultValue, defaultValue: false)); } ncTimeItem.Add("key", Guid.NewGuid().ToString()); ncTimeItem.Add("ncContentTypeAlias", time.ContentType.Alias); ncTimeItem.Add("meetingdateTimeItem", time.Value<string>("meetingdateTimeItem", fallback: Fallback.ToDefaultValue, defaultValue: null)); ncTimeItems.Add(ncTimeItem); } ncDateItems.Add(ncDateItem); } ncItems.Add(ncDateItems); var ncItemString = Newtonsoft.Json.JsonConvert.SerializeObject(ncItems); mainpage.SetValue("meetingDatesAvailable", ncItemString); contentService.SaveAndPublish(mainpage); return new { saved = ncItemString }; }
I am really uncertain how to structure the list correctly.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Update nested content in nested content with ContentService
I have a nested content list (meetingItemDayTimes) inside nested content list (meetingDatesAvailable).
I want to set a checkbox to true on the each time item. But I can't for the life of me get it to work.
The structure is like:
My code is this:
I am really uncertain how to structure the list correctly.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.