is it possible to link to a google form from a custom menu. I have a google sheet set up that receives the results of a google form. I have a custom menu, but want to link directly to the 'viewform' url of the google form when the user selects the menu item (I realize this is not perhaps conventional use of google form, but I really don't want users directly editing the sheet to input data).
Below is what I have so far...
function onOpen() {
var ui = SpreadsheetApp.getUi();
// Or DocumentApp or FormApp.
ui.createMenu('Century Items')
.addItem('Add to RedBook', 'menuItem1')
}
function menuItem1() {
var form = UrlFetchApp.fetch(https://docs.google.com/forms/d/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/viewform);
}
Not quite sure how to finish it and I keep getting the error "Missing ) after argument list" I've looked at other possibilities such as
var form = FormApp.openByUrl('url')
etc..., but not quite sure how to implement them.
I'm definitely new to java-script so any help is appreciated.
EDIT: Working Script with the help of Serge:
function onOpen() {
var ui = SpreadsheetApp.getUi();
// Or DocumentApp or FormApp.
ui.createMenu('Century Items')
.addItem('Add to RedBook', 'menuItem1')
.addToUi();
}
function menuItem1() {
showURL("https://docs.google.com/forms/x/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/viewform")
}
function showURL(href){
var app = UiApp.createApplication().setHeight(50).setWidth(200);
app.setTitle("Add to Redbook");
var link = app.createAnchor('Open Red Book Form ', href).setId("link");
app.add(link);
var doc = SpreadsheetApp.getActive();
doc.show(app);
}