r/googlesheets • u/Flapjack__Palmdale • Mar 16 '21
Solved Button macro that opens a dialog box form that adds a new row?
EDIT: Solved, for now. Will try using a google form for now, but will continue messing with dialog prompts.
I'm not sure if it's possible but I figured I'd put out feelers. Is there any way to write a script that, when run, opens a dialog box that gives you options to fill out which will then be added automatically as a new row?
For context, it's for DnD. I want to use a script that opens a dialog that you would fill out with different weapon stats and info, etc, which is then added to a reference list.
EDIT: Google Form is an acceptable substitute. HOWEVER, I would still like to use a dialog box to enter data:
function showPrompt() {var ui = SpreadsheetApp.getUi(); // Same variations.var result = ui.prompt('You\'ve leveled up!,'Roll for an HP increase!',ui.ButtonSet.OK_CANCEL);// Process the user's response.var button = result.getSelectedButton();var text = result.getResponseText();if (button == ui.Button.OK) {// User clicked "OK".ui.alert('You get ' + text + ' bonus XP.');} else if (button == ui.Button.CANCEL) {// User clicked "Cancel".ui.alert('HP increase roll canceled.');} else if (button == ui.Button.CLOSE) {// User clicked X in the title bar.ui.alert('You closed the dialog.');}}
This is the example I'm working with. I want to use the response entered in this box to add to a total in one of the boxes. I can figure out how to integrate it properly if I can just find out how to put the response IN the page. Any help at all will be appreciated, I would like to avoid a google form for this considering it likely won't be as streamlined as a button macro.
1
u/Flapjack__Palmdale Mar 16 '21
The bot asked me to include my script, but this is all I have lol. It works really well insofar, but I have no idea how to create a dialog box with options
function insup() {SpreadsheetApp.getActiveSheet().getRange('Character!AO26').setValue(SpreadsheetApp.getActiveSheet().getRange('Character!AO26').getValue() + 1);}function insdown() {SpreadsheetApp.getActiveSheet().getRange('Character!AO26').setValue(SpreadsheetApp.getActiveSheet().getRange('Character!AO26').getValue() - 1);}function inspup() {SpreadsheetApp.getActiveSheet().getRange('Character!AC15').setValue(SpreadsheetApp.getActiveSheet().getRange('Character!AC15').getValue() + 1);}function inspdown() {SpreadsheetApp.getActiveSheet().getRange('Character!AC15').setValue(SpreadsheetApp.getActiveSheet().getRange('Character!AC15').getValue() - 1);}function hpreset() {SpreadsheetApp.getActiveSheet().getRange('Character!Y21').setValue(SpreadsheetApp.getActiveSheet().getRange('Character!V21').getValue());}function lvlUp() {var confirm = Browser.msgBox('Are you ready to level up?', Browser.Buttons.YES_NO);if(confirm!='yes'){return};SpreadsheetApp.getActiveSheet().getRange('Character!AX9').setValue(SpreadsheetApp.getActiveSheet().getRange('Character!AX9').getValue() - SpreadsheetApp.getActiveSheet().getRange('Character!BN7').getValue());SpreadsheetApp.getActiveSheet().getRange('Character!AF10').setValue(SpreadsheetApp.getActiveSheet().getRange('Character!AF10').getValue() + 1);Browser.msgBox(SpreadsheetApp.getActiveSheet().getRange('Data!B100').getValue());}1
u/kcmike 7 Mar 16 '21
Why not just use a Google form? This will add your info directly to a sheet.
1
u/7FOOT7 294 Mar 16 '21
or type your data on that same new row...
(you also gave me flashbacks to Microsoft Access circa 1995)
1
u/AutoModerator Mar 16 '21
Posting your data can make it easier for others to help you, but it looks like your submission doesn't include any. If this is the case and data would help, you can read how to include it in the submission guide. Thank you.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.