Dialogue Button Text

391 views
Skip to first unread message

cri...@gmail.com

unread,
Apr 26, 2019, 8:13:37 AM4/26/19
to Google Apps Script Community
From what I read on the developers site, I should be able to change the text in the button of a dialogue box by using this code:


var result = ui.prompt(
      'Title',
    'Message',
      ui.ButtonSet.OK_CANCEL);
  var button = result.getSelectedButton();
  //What happens if the User clicks OK
  if (button == ui.Button.OK) {

Using this works fine, but when I try to change the text I get an error:


var result = ui.prompt(
      'Title',
    'Message',
      ui.ButtonSet.SUBMIT_CANCEL);
  var button = result.getSelectedButton();
  //What happens if the User clicks OK
  if (button == ui.Button.SUBMIT) {

You can see that I've changed the text to submit from OK.

The documentation states that:

To override the default "OK" button, pass a value from the Ui.ButtonSet enum as the buttons argument.

However from what is written online, it's not possible to change the text.

Can someone clarify this for me, and if it's possible point me in the correct direction?

Martin Hawksey

unread,
Apr 26, 2019, 2:59:06 PM4/26/19
to google-apps-sc...@googlegroups.com
You can change the button text but it is restricted to the listed Enum's 

PropertyTypeDescription
OKEnumA single "OK" button, indicating an informational message that can only be dismissed.
OK_CANCELEnumAn "OK" button and a "Cancel" button, allowing the user to either proceed with or halt an operation.
YES_NOEnumA "Yes" button and a "No" button, allowing the user to answer a yes/no question.
YES_NO_CANCELEnumA "Yes" button, a "No" button, and a "Cancel" button, allowing the user to either answer a yes/no question or halt an operation.

If you want more control over your dialog appearance you can use HTMLService ... more info on Custom dialogs

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-script-community.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/af9960c9-d333-4d1b-adf1-2b948ae36f3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Martin Hawksey

Latest tweet (see how):

Come and listen to a recap of G Suite sessions from #GoogleNext19 with @CinFourThirds and myself, hosted by the venerable @mhawksey! 👇 https://t.co/q67MaCmihN

— Ben Collins (@benlcollins) April 19, 2019
Reply all
Reply to author
Forward
0 new messages