Question

I'm trying to create a timeline based on a task list from a provider-hosted add-in. I have found out how it works and I'm able to create the task list and add the timeline web part, but I can't add or update the necessary properties on the task list to get the items to actually show on the timeline.

I'm currently getting the list by:

var list = clientContext.Web.Lists.GetByTitle("Tasks");
clientContext.Load(list, l => l.RootFolder.Properties);
clientContext.ExecuteQuery();

This works fine i get to see all the properties and if I manually add the tasks to a timeline I can see how it changes. But when I try to change the properties or just add them it doesn't work. I have tried to following to get it to stick:

list.RootFolder.Properties.FieldValues.Add("TimelineAllViews", "Timeline");
list.RootFolder.Properties.FieldValues.Add("TimelineDefaultView", "Timeline");
list.RootFolder.Properties.FieldValues.Add("Timeline_Timeline",WebPartXML.TimelineXML);
list.RootFolder.Update();
clientContext.ExecuteQuery();

I have also tried to load the list and/or folder before updating and also using update on list and/or folder.

Thanks for any help.

Was it helpful?

Solution

After some more trying I finally found a way, might not be the best but this is how I got it to work. So first you add the values to the list and then you have to update them again to make it stick. Why it's not enough to just add them I don't know.

folder.Properties.FieldValues.Add("TimelineAllViews", "Timeline*");
folder.Properties.FieldValues.Add("TimelineDefaultView", "Timeline");
folder.Properties.FieldValues.Add("Timeline_Timeline", WebPartXML.TimelineXML);
folder.Properties["TimelineAllViews"] = "Timeline*";
folder.Properties["TimelineDefaultView"] = "Timeline";
folder.Properties["Timeline_Timeline"] = WebPartXML.TimelineXML;
folder.Update();
clientContext.ExecuteQuery();
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top