Question

So I have a custom task list with a timeline view. I have removed the list below the timeline using CSS in the script editor web part so users can see a timeline of ongoing projects and click on the blocks to see more information.

The only issue I have now is needing to manually add each item to the timeline. I have searched for ways to do this automatically and the very limited info out there isn't exactly helpful...

Does anybody know of a way to this or why Microsoft decided to not include this as an option as I have found tonnes of other people asking the same question with no answers?

Était-ce utile?

La solution

The Timeline data is actually embedded as properties of the Rootfolder of the Task list. There are three properties for the default timeline control, TimeLineDefaultView, TimeLineAllViews and TimeLine_TimeLine.

Set these properties to the following value using the code to achieve that.

  • TimeLineDefaultView: Timeline
  • TimeLineAllViews: Timeline*
  • Timeline_Timeline: … (XML)

For example:

$TimelineAllViews = "Timeline*"
$TimelineDefaultView = "Timeline"
$Timeline_Timeline = '<TLViewData><fltSet><ft id="{00000000-0000-0000-0000-000000000000}" uid="4294967295" uidSrc="1" onTL="0" fmt="1" x="0" y="4294967282" h="20" /></fltSet><fmtSet><fmt id="0" type="0" clr="FFEE2222" thm="0001" t1="0" t2="1" /><fmt id="1" type="1" clr="FFEE2222" thm="0001" t1="2" t2="3" /><fmt id="2" type="2" clr="FFEE2222" thm="0001" t1="4" t2="5" /><fmt id="3" type="3" clr="FFEE2222" thm="0001" t1="6" t2="7" /></fmtSet><mlSet><m id="{00000000-0000-0000-0000-000000000000}" uid="4294967295" uidSrc="1" onTL="0" fmt="2" x="0" y="35" /><m id="08d7f35a-3a35-4540-83ab-a1f2cb63e448" onTL="1" barid="1" fmt="2" y="35" x="0" uid="2" uidSrc="1" /><m id="f115a910-6edc-40e3-b8fc-faabfa09f76e" onTL="1" barid="1" fmt="2" y="35" x="0" uid="3" uidSrc="1" /></mlSet><options dateFormat="255" minMode="0" numTextLines="1" panZoomT="9" ProjSummFmt="3" round="1" showDates="1" showOverlaps="1" showPanZoom="" showProjSummDates="0" showToday="1" showTS="1" timelineWidth="-1" timescaleT="8" todayT="10" zoom2Screen="1" timelineHeight="133" /><tskSet><t id="{00000000-0000-0000-0000-000000000000}" uid="4294967295" uidSrc="1" onTL="0" fmt="0" ch="4294967295" /><t id="08d7f35a-3a35-4540-83ab-a1f2cb63e448" onTL="1" barid="1" fmt="0" ch="4294967295" uid="2" uidSrc="1" /><t id="f115a910-6edc-40e3-b8fc-faabfa09f76e" onTL="1" barid="1" fmt="0" ch="4294967295" uid="3" uidSrc="1" /></tskSet><txtSet><style id="0" shared="0" type="0" clr="FFEE2222" thm="0001" sz="8" font="Segoe UI" bold="0" ital="0" und="0" strk="0" /><style id="1" shared="0" type="1" clr="FFEE2222" thm="0001" sz="8" font="Segoe UI" bold="0" ital="0" und="0" strk="0" /><style id="2" shared="0" type="2" clr="FF999999" thm="0001" sz="8" font="Segoe UI" bold="0" ital="0" und="0" strk="0" /><style id="3" shared="0" type="3" clr="FFB3B3B3" thm="0001" sz="8" font="Segoe UI Light" bold="0" ital="0" und="0" strk="0" /><style id="4" shared="0" type="4" clr="FF525051" thm="0001" sz="10" font="Segoe UI" bold="0" ital="0" und="0" strk="0" /><style id="5" shared="0" type="5" clr="FFB3B3B3" thm="0001" sz="8" font="Segoe UI Light" bold="0" ital="0" und="0" strk="0" /><style id="6" shared="0" type="6" clr="FF999999" thm="0001" sz="9" font="Segoe UI" bold="0" ital="0" und="0" strk="0" /><style id="7" shared="0" type="7" clr="FF999999" thm="0001" sz="8" font="Segoe UI" bold="0" ital="0" und="0" strk="0" /><style id="8" shared="0" type="8" clr="FF999999" thm="0001" sz="8" font="Segoe UI" bold="0" ital="0" und="0" strk="0" /><style id="9" shared="0" type="9" clr="FFFFA614" thm="0001" sz="8" font="Segoe UI Semibold" bold="1" ital="0" und="0" strk="0" /><style id="10" shared="0" type="10" clr="FFFFA72B" thm="0001" sz="10" font="Segoe UI Semibold" bold="0" ital="0" und="0" strk="0" /></txtSet><tlbarSet><tl id="0" startDate="" finishDate="" /><tl id="1" /></tlbarSet></TLViewData>'
$site = Get-SPSite "http://sp/sites/<site>"
$web = $site.RootWeb
# create and retrieve the new list
$list = $web.Lists["<Task List>"]
# set the timeline properties and update
$list.RootFolder.Properties["TimelineAllViews"] = $TimelineAllViews
$list.RootFolder.Properties["TimelineDefaultView"] = $TimelineDefaultView
$list.RootFolder.Properties["Timeline_Timeline"] = $TLxml.OuterXml
$list.Update()

Demos about how to add tasks to timeline automatically:

Can I automatically add Tasks to the Timeline

http://www.c-sharpcorner.com/forums/add-new-task-item-to-timeline-using-programmatically-c-sharp

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top