SharePoint Hosting News: How to Adding Multiple Timelines Graph to a Project

How to Adding Multiple Timelines Graph to a Project

When creating a SharePoint site using the project template a default timeline view is created. A timeline view provides the graph which shows tasks with dependencies on a timeline format.  The limitation with this template is that there is only one timeline view created, and we often find the need to create more than one. In this article, we take a look at how we can add additional timeline properties on a project site by using the SharePoint JavaScript Client Object Model (COM).

timeline

FIND THE LIST FOLDER URL

In order to add a new timeline view, we first need to find out the URL for the list folder properties.  This URL is needed to query for the list properties using JavaScript. The URL can be found by visiting Site Content->List Name->List Settings. This link should have this format:

http://sp.site.com/blog/Lists/FolderName/AllItems.aspx

The highlighted text is the information that we need to query the properties.

SCRIPT TO LOAD THE LIST PROPERTIES

Now that we have the folder name, we can move on to write the script that can help us query the properties information. We start by creating a JavaScript function which can let us define the request and then make a call to display the properties.  The goal here is to become familiar with the SharePoint Client Object Model (COM).

The function just makes the call and displays the results on the browser console. This can help us inspect the results and discover what property we need to clone. After looking at the results, we should find a property with the name of “Timeline_Timeline”.  This is the property that contains the metadata for the timeline graphs.

SCRIPT TO CLONE A TIMELINE VIEW

Now that we know how to query the properties, we can focus on how to clone one. The goal is that we need to create additional timeline properties. This is what allows us to create additional graphs on the project.  In order to clone a property, we can leverage our first script to query the properties collection. The change now is that instead of just displaying the properties, we can fetch the property value and create a new one by calling set_item(newPropName, value) on the collection object and update the folder information. This is what adds a new property.

SIMPLE WAY TO USE THIS SCRIPT

This script can be loaded from a SharePoint page that includes the SP JavaScript files. The approach to do this is to edit the page and add the script editor web part to the page. This allows us to add embedded script and quickly test our JavaScript changes by reloading the page with the script and calling the functions using the browser console. For example, open the browser console and type:

findProperties(‘’sitename/Lists/Tasks’’)

We could also just add an HTML button and wire the onclick event to call our function.

That should add another timeline with the name Timeline_Timeline2

VALIDATE THAT WE HAVE NEW TIMELINES

After we run the script, we can now edit the default project plan page and edit the timeline web part properties. On the timeline views, we should see a dropdown with the list of views that are available. Depending on the number of times that you clone a timeline, you should see that many entries.

Keep in mind that the selected view becomes the default timeline. This is important to know because when you add items to the timeline from the task lists, the items are added to the default timeline view.

Best SharePoint Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers SharePoint hosting starts from $9.99. ASPHostPortal.com also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable SharePoint Hosting, ASPHostPortal should be your best choice.