Reputation: 13
How do we read the values of the UI elements from the click event for the Submit button? Have I missed something simple? Aka, going into this I assumed there was an Apps Script object that would help read the Card UI elements? Am I mistaken, and have to revert to basic javascript here, if so, any examples within the GApps space as I new to this would help out. thanks.
I have a Google Workspace Addon using Apps Script and the Card Service for the UI. Addon is run via icon from Gmail, Sheets, etc. The Card UI collects a few simple values with text fields and a few dropdowns. When done and clicking the Submit button we'd like to submit those values to an external web service. (Calling another external web service for the dropdown values works just fine, btw)
setupfunc() {
let cardSection1TextInput1 = CardService.newTextInput()
.setFieldName('name')
.setTitle('Name')
.setMultiline(false);
... ...
let cardSection1ButtonList1Button1Action1 = CardService.newAction()
.setFunctionName('processClick');
let cardSection1ButtonList1Button1 = CardService.newTextButton()
.setText('Submit')
.setBackgroundColor('#66b73a')
.setTextButtonStyle(CardService.TextButtonStyle.FILLED)
.setOnClickAction(cardSection1ButtonList1Button1Action1);
}
...
function processClick(e)
{
// Is there a Card Service/Apps Script helper to read the UI input value for name?
// can't appear to grab values off of e of any relevance so far...
var userdata_name = ????
var response = UrlFetchApp.fetch("url", options); // this will just work once we have data
}
Upvotes: 0
Views: 1011
Reputation: 13
e.formInputs
is the answer I found buried in official Google sample code. So, e.formInputs.name
is what I need.
Did a search with formInputs and found this post already asked: Link
Upvotes: 1