I'm looking for a way to append new ListItem to particular list in Google Docs API.
My problem is that I can't figure out how to determine last item in list, so I could just insert new item using it's index. My vision of how to implement this looks like:
body.insertListItem(body.getChildIndex(lastItem) + 1, newItem);
P.S. Am I doing something wrong, maybe there is some other way to implement appending?
Thanks in advance!
A ListItem is a
Paragraphthat is associated with a list ID. AListItemmay contain Equation, Footnote, HorizontalRule, InlineDrawing, InlineImage, PageBreak, and Text elements. For more information on document structure, see the guide to extending Google Docs.ListItems with the same list ID belong to the same list and are numbered accordingly. The ListItems for a given list are not required to be adjacent in the document or even have the same parent element. Two items belonging to the same list may exist anywhere in the document while maintaining consecutive numbering, as the following example illustrates: