Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 368
bhavesh Avatar asked Jul 25 '26 02:07

bhavesh


2 Answers

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?

like image 69
Tanaike Avatar answered Jul 26 '26 14:07

Tanaike


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

like image 34
Stephen Shaw Avatar answered Jul 26 '26 14:07

Stephen Shaw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!