How to create new Person, Date, RichLink Elements in Google Doc

29 views
Skip to first unread message

Dametrius King

unread,
Sep 10, 2021, 1:50:04 PMSep 10
to Google Apps Script Community
Hello everyone,

I see that Google has updated the Apps Script documentation to add info regarding Date, Person, and RichLink elements. Most of the methods for the classes reference getting metadata for the element but no info about setting properties of the element. For example, for a RichLink element, I can get the title and URL but I can't set this info.

Does anyone know how to create new instances of the above classes and set the relevant attributes?

dimud...@gmail.com

unread,
Sep 10, 2021, 4:14:22 PMSep 10
to Google Apps Script Community
RichLink has a setAttributes method, so that seems like a good place to start. 

Also, navigating up the inheritance chain you'll find that RichLink implements the Element interface and extends the ContainerElement class so I'd take a look at those as well.

dimud...@gmail.com

unread,
Sep 10, 2021, 4:16:26 PMSep 10
to Google Apps Script Community
Forgot to mention. It appears you can't create new instances of those classes but since they implement the Element interface they all support the copy() method.

Dametrius King

unread,
Sep 14, 2021, 11:19:31 AMSep 14
to Google Apps Script Community
Hi,

Thanks for the suggestion but I've tried using the setAttributes() method and no change is made to the element. I've also tried to copy() the element but this just creates an identical element of the same ElementType that also can't be modified. 

dimud...@gmail.com

unread,
Sep 14, 2021, 11:31:18 AMSep 14
to Google Apps Script Community
Look at the inherited functions from the ContainerElement class, maybe there's something there you can use.
Reply all
Reply to author
Forward
0 new messages