Open Url and Action At Same Button

107 views
Skip to first unread message

Nibesh Khadka

unread,
Nov 25, 2022, 10:29:53 AM11/25/22
to Google Apps Script Community
Hi, I am trying to assign on click action function and open the URL with one button click. It's not happening; the function part; is only the URL gets opened up. 

CardService.newTextButton()
.setText("<font color='black'> Go</font>")
.setBackgroundColor("#f9a825")
.setTextButtonStyle(CardService.TextButtonStyle.FILLED)
.setOnClickAction("some action")
.setOpenLink(
CardService.newOpenLink()
.setUrl("some link")
.setOpenAs(CardService.OpenAs.FULL_SIZE)
.setOnClose(CardService.OnClose.RELOAD_ADD_ON)
);

Thanks.

Paul Armstrong

unread,
Nov 27, 2022, 3:37:08 PM11/27/22
to Google Apps Script Community
Set the link in as a parameter to the Action you created. 
And then get "some action" to do its stuff and then open the link. 

function someAction(event) {
// do stuff.
var url = event.... 

return CardService.newUniversalActionResponseBuilder()
.setOpenLink(CardService.newOpenLink()
.setOpenAs(CardService.OpenAs.FULL_SIZE)
.setUrl(url))
.build()
;
}

Reply all
Reply to author
Forward
0 new messages