locked
timeline add an event using javascript RRS feed

  • Question

  • I have a task list and i want to add an event to the timeline with callout format without the user action.

    So after looking for, using the javascript funciont found in sp.ui.timeline.js:

     AddItemsToTimeline([{ 'id': itemID }], listId, 'Timeline');

    i was able to add the list items to the timeline but i need to add them as a callout, so i suspect has to been added with the parameter fmt = 2 instead of the default value fmt = 0.

    I tried using:

    AddItemsToTimeline([{ 'id': itemID,`fmt':2 }], listId, 'Timeline');

    but just don't work.

    please some help with this.

    Thank you in advance.


    • Edited by JLSF Monday, February 16, 2015 9:36 AM
    Monday, February 16, 2015 9:35 AM

All replies

  • Hi,

    According to your description, my understanding is that you want to add an event to timeline with callout format.

    SP.SOD.executeFunc("callout.js", "Callout", function AddNewTaskToTimeline(itemID, listId) {
    AddItemsToTimeline([{ 'id': itemID }], listId, 'Timeline');
    });

    Here are some detailed articles for your reference:

    http://www.sharepointknight.com/2014/03/sharepoint-2013-add-to-timeline-programmatically/

    https://msdn.microsoft.com/en-us/library/office/dn135236.aspx

    Thanks

    Best Regards

    Forum Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Jerry Guo
    TechNet Community Support


    Tuesday, February 17, 2015 7:06 AM
  • Hi Jerry,

    thanks for your answer. This is not exactly what i´m looking for there is a misunderstanding about callout meaning. If you go to a timeline webpart select a event/task you got a button with "callout" this means the event is attached to the timeline as a callout.

    The Sharepointknight.com webpage was my inspiration... so following his exaplanations I was able to add a event but I was NOT able to add it with callout format.

    Thanks


    • Edited by JLSF Tuesday, February 17, 2015 9:17 AM
    Tuesday, February 17, 2015 9:01 AM
  • Hi,

    The timeline web part display tasks as bar by default. If you need to add the item as a callout format, no need to set in the code, you can switch the format using "Display as callout" in the ribbon.

    Thanks

    Best Regards

    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Jerry Guo
    TechNet Community Support

    Friday, February 20, 2015 5:33 AM
  • Thanks Jerry, 

    yes the timeline is an awesome webpart. We are using the JavaScript methods to add a tasjk to timeline programatically, so don't have sense to tell user to later go task by task pùshing the call out button.

    This is the main reason i ask about how to add the task with the callout format, it's about fmt=2 parameter?

    it is posible to pass in the json object with this format?

    Thanls


    • Edited by JLSF Friday, February 20, 2015 9:57 AM
    Friday, February 20, 2015 9:56 AM
  • Hi,

    As far as I am know, in the JavaScript API, there is no such parameter to define the timeline task format.

    You can set the timeline xml schema with fmt value to achieve it .

    Here are some code demos for your reference:

    http://sharepoint.stackexchange.com/questions/112410/can-i-automatically-add-tasks-to-the-timeline

    http://dinushaonline.blogspot.com/2014/08/programmatically-add-tasks-to-timeline.html

    Thanks

    Best Regards

    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Jerry Guo
    TechNet Community Support

    Tuesday, February 24, 2015 6:19 AM
  • Hi,

    I have a similar requirement. Can you tell me how you added the task to timeline automatically? Is it possible to add mulitple items in timeline using powershell script?

    In my requirement: A master task list is being populated with tasks from various subsites using a powershell script, so I want to add all those tasks from master task list to be directly added to timeline so that there is no user intervention.

    Please suggest/ share some thoughts.

    Thanks

    Monday, July 6, 2015 8:40 AM
  • Hi, could you please share the code about how did you add a task to the timeline using JavaScript?

    Do you think it could work for Sharepoint Online (Office 365) ?

    Thanks in Advance,

        Alejandro

    Wednesday, March 8, 2017 1:45 PM