How to use the add_timeline_item client side function

Hello

I’m trying to figure out how to use the add_timeline_item function in a client script
As can be seen in the screen shot, what is the nature of the “item” parameter? Is it a string, an object, etc?

In general, how can I use the browser’s DevTools to figure out the nature of any function’s parameters?

Screenshot from 2023-12-23 13-17-13

I figured out some of the parameters, and the following works well, creating a new entry in the Timeline.

frm.timeline.add_timeline_item({content:"meep", creation:frappe.datetime.now_datetime()},false);

However, even if I save the document, the Timeline entry is not retained, but lost should I refresh the document. How can I persist the Timeline entry? It appears that

frm.timeline.insert_comment();

is no longer available in v15

Some further investigation revealed that directly after a

cur_frm.timeline.add_timeline_item({content:“Custom Content”}, false);

any of these commands actually removes the timeline item

cur_frm.timeline.refresh();
cur_frm.timeline.render_timeline_items();
cur_frm.save();

Yet I have no idea how to persist the timeline item so that it actually renders again upon a form refresh.

I’m guessing you’ve likely sorted this out but since this just came up in one of my searches I thought it would be worthwhile adding the following information for future viewers:

The “timeline” object is itself just a rendering of the timeline information, the entries in the timeline are transient and are generated dynamically from a combination of entries drawn from doc fields (e.g. “created” => “You created this …” and “modified” times => “You last edited this …”) and “Comment” docs. (Possibly others but that’s all I’ve looked at myself).

So when you manually add entries to the timeline you have to do that each time the form is rendered, they aren’t permanent.

For my use case I created doctype “Comment” docs setting the “reference_doctype” and “reference_docname” fields appropriately. These then get rendered in the timeline for the given doc “automatically”.

Hopefully someone will correct/update this information if needed.