setOnChangeAction example

358 views
Skip to first unread message

Paul Armstrong

unread,
Apr 11, 2022, 3:35:48 AM4/11/22
to Google Apps Script Community
Hello
I want to text entered into a TextInput changed to lowercase as the user enters new text (or at least after they have left the field).

An Action function triggered through TextInput::setOnChangeAction(...) does hear the change and the event passed to the Action function has the value I want to change. 
But it is not obvious how to change the value on the original TextInput object. 

function setup() {
  var action = CardService.newAction().setFunction("on_change");
  var text CardService.newTextInput().setOnChangeAction(action);
}
function on_change(event) {
   // do what to change the value of the text object?
}

Thank you!

Dora Samy

unread,
Jun 21, 2022, 2:55:55 PM6/21/22
to Google Apps Script Community
Hi,
Did you find a way for this?

Paul Armstrong

unread,
Jun 21, 2022, 6:18:42 PM6/21/22
to Google Apps Script Community
Hi
Not in real-time, no. I end up doing it after the fact.
I think the closest to being able to do it (as the user types or before they submit the form) would be as per this API and example  https://developers.google.com/apps-script/reference/card-service/text-input?hl=en#setSuggestionsAction(Action) 

Good luck. 

Dora Samy

unread,
Jun 22, 2022, 5:28:19 AM6/22/22
to google-apps-sc...@googlegroups.com
I ended up navigating another card with the updated values, though it might not be the correct way to do it.


--
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/fZ5OBYwCjzI/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/258a548e-7f86-4935-b07d-ba0d60a77f08n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages