Status Update
Comments
mi...@google.com <mi...@google.com> #2
Hello there!
Thank you for filing this.
Currently, the content related to these elements can only be read by getting the corresponding
In this case, you could iterate through the different body elements and handle each one appropriately according to the element type. Do you think this could be a feasible workaround for you? If you think that's the case but are unsure how to implement this, I'd suggest you to visit
If that's not the case and you'd like to get all this content at once via body.getText()
, can you provide more information regarding your current situation? More specifically:
- What impact (in terms of productivity, costs, etc.) could this feature have in your current situation?
- What workaround (if any) are you currently using?
Kind regards.
mu...@gmail.com <mu...@gmail.com> #3
Hello!
Thank you for the quick reply.
For now this solution is good enough, I appreciate it.
However, I am facing another one, which is two-fold.
- Accessing a checkbox state → Today not possible, I assume (check
) StackOverflow - Carrying over check box state over Google Documents → Also not possible
Regarding the item two, whenever I try to move a given List Item which is a checkbox, it won't carry the GLYPH over (please check the screenshot) .
This is the code I am using, by running backupHistory()
.
function backupHistory() {
var mainDocId = '1Fm5YeuJ-B0JPSyxtmN4iFd1m_iK1wzaBz2bijsncDEQ';
var historyDocId = '1uA96M7NVXt27jEjP57uG6VYgNjQFkfHuSTzJiN_u-Fg';
var histElements = filterElements(mainDocId, new Date());
appendElements(historyDocId, histElements);
}
function filterElements(docId, toDate) {
var elements = []
var doc = DocumentApp.openById(docId);
var childrenCount = doc.getNumChildren();
for (var i = 0; i < childrenCount; i++) {
var element = doc.getChild(i).copy();
elements.push(element);
}
return elements;
}
function appendElements(docId, elements) {
var doc = DocumentApp.openById(docId);
var body = doc.getBody();
for (var e of elements) {
var type = e.getType();
if (type == DocumentApp.ElementType.PARAGRAPH)
body.appendParagraph(e);
else if (type == DocumentApp.ElementType.TABLE)
body.appendTable(e);
else if (type == DocumentApp.ElementType.LIST_ITEM)
body.appendListItem(e);
else
throw new Error("Unknown element type: " + type);
}
}
My current workaround is changing the style of the elements manually, but that is not ideal.
Can you tell if these features will be introduced?
Otherwise, I'll have to move to Notion, or other note taking app for my extension.
mi...@google.com <mi...@google.com> #4
About your follow-up questions, these are not related to the original request, so I'll proceed to close this now. Consider filing a new issue for this.
In any case, regarding the checklists, have you tried getting the original elements'
Description
A short description of the issue:
A small code sample that reliably reproduces the issue. The sample should run as-is or with minimal setup, without external dependencies.
After creating an Google Docs with dynamic elements (e.g., date, event, contact), run the script below on a App Script.
The logged output will differ from the Body text, since the dynamic elements won't be found.
What steps will reproduce the problem?
What is the expected output? What do you see instead? If you see error messages, please provide them.
Expected output: Text containing dynamic element, e.g. a date should be rendered as the text seen over Google Docs.
Please provide any additional information below.
Ideally, it should be possible not only to read but also to write these dynamic elements to Google Docs via App Scripts.