How to insert RichLink (Chip Block) in Google Docs using Google App Script
Asked Answered
V

2

7

enter image description here

Google Docs has recently introduced a feature where we can refer to

  • Date
  • Person
  • Google Drive Document

in the form of a Chip Block (as shown in the picture above). The Document-A already exists in Google Drive.

Currently the only way to generate such Chip Block is to manually hover the document link and then click Replace URL - Chip in the pop up modal that appears.

I am trying to generate such chip block using Google App Script but have not been successful so far.

Rich Link Documentation does not have any code snippet or method to add a Rich Link inside a document.

Document Service page also doesn't have detail regarding how to insert a Rich Link.

I wonder whether the feature is not yet implemented in the Google App Script Api

EDIT

As mentioned by Stephen Shaw this issue has been flagged on Google Issue Tracker Create and insert smart chips by maclir. Hoping for an early implementation of this feature.

Venus answered 31/10, 2021 at 5:57 Comment(0)
K
9

The smart chips can be retrieved using the methods released on August 23, 2021. Ref. But, unfortunately, in the current stage, it seems that there are no methods for inserting the smart chips. Although I checked about this at both Google Document service and Google Docs API, I couldn't find the methods for this. So, I think that is the current answer.

And also, when I checked the Google issue tracker, I couldn't find anything about your goal. Ref So, how about reporting your goal as a future request at the issue tracker?

Kimmel answered 31/10, 2021 at 6:35 Comment(1)
I created this request.Fool
H
2

There is now a Issue Tracker on Create and insert smart chips that has 161 votes.

I use a workaround for insert smart chips. My Google Doc Addon inserts it as a link. When the user hovers over the link, the Google Docs interface gives them an option of converting to a SmartChip

let urlDoc = DocumentApp.getActiveDocument().getUrl();
let para = DocumentApp.getActiveDocument().getBody().insertParagraph(index,urlDoc);
para.setLinkUrl(urlDoc);  

View of cursor hovering over link, with option to convert to chip

Hymenopteran answered 23/3, 2023 at 16:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.