CardService: How to align ButtonSet to the Right/end ?

727 views
Skip to first unread message

Serge K.

unread,
Jan 6, 2023, 1:05:24 PM1/6/23
to Google Apps Script Community
Hi all,

I am building two add-on for Google Workspace using Apps Script and the Alternate Runtime.

I am having trouble aligning a ButtonSet to the right/end using Apps Script syntax.

Using the Card Builder Tool allows to align button sets to the start, center or end. The JSON output shows a key value pair of "horizontalAlignment": "END" for the widget.

However, no apps script output is generated. it seems, there is not "Setlayout" or "setAlignment" and we can not use the CardService.HorizontalAlignment.END with ButtonSet

How are you doing to align a ButtonSet to the end ? is there a workaround?

thank you in advance for the feedback.

Serge K.

Avana Vana

unread,
Jan 11, 2023, 10:19:56 AM1/11/23
to Google Apps Script Community
Hi,

As far as I am aware, only the GridItem class has a setTextAlignment() method which can accept one of the HorizontalAlignment Enum values.

I do not think you can use the HorizontalAlignment Enum with the ButtonSet class.

As the Card Builder Tool itself says: "Horizontal alignment. Note: Some widgets are always full width and ignore this setting."

Best,
Avana

Serge K.

unread,
Jan 11, 2023, 10:26:02 AM1/11/23
to google-apps-sc...@googlegroups.com
Thank you for the feedback Avana,

I think I will just trick it by using a DecoratedText with an empty text and the right button activated.  It will do the job for now.

Thanks again!

 Serge K



--
You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/EizQ_ffUKhY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/afd247f1-eafa-4506-bca9-0ba075954756n%40googlegroups.com.
Message has been deleted

Gabriel Villoldo

unread,
Jul 27, 2023, 7:18:32 PM7/27/23
to Google Apps Script Community
I am experiencing the same issue, the Card Builder Tool says that ButtonSet accepts "horizontalAlignment", it works perfectly using JSON implementation, but it does NOT work using AppScript editor using CardService. According to the API RPC there is no "horizontalAlignment" https://developers.google.com/workspace/add-ons/reference/rpc/google.apps.card.v1#buttonlist, but it does work ok. That's the inconsistency that Serge K is pointing. Is Google going to update API RPC and CardService to support "horizontalAlignment" in ButtonSet/ButtonList?

Thanks!

Gabriel Villoldo

unread,
Jul 27, 2023, 7:21:22 PM7/27/23
to Google Apps Script Community

Ori Seri

unread,
Aug 1, 2023, 1:31:01 AM8/1/23
to Google Apps Script Community
Hi,
I'm experiencing the same issue. Card JSON supports "horizontalAlignment" in card builder, but I cannot set it programmatically in AppsScript.
Will be glad if it can be addressed 🙏🏻

Pracownia Alternatywna

unread,
Aug 2, 2023, 4:48:47 AM8/2/23
to Google Apps Script Community
Same here, is there anyway to LEFT, CENTER, RIGHT align all the widgets not just GridItems?
Reply all
Reply to author
Forward
0 new messages