function NewItem() {
var doc = SpreadsheetApp.getActiveSpreadsheet();
var app = UiApp.createApplication().setTitle('My Application');
var panel = app.createVerticalPanel();
var lb = app.createListBox(true).setId('myId').setName('myLbName');
var sh = SpreadsheetApp.getUi();
var response = sh.alert("Confirm!", "This will delete the selected item in all sheets, do you want to continue?", sh.ButtonSet.OK_CANCEL)
if (response == sh.Button.OK)
{
// List of categories for user to select
lb.setVisibleItemCount(9);
lb.addItem('Category 1');
lb.addItem('Category 2');
lb.addItem('Category 3');
lb.addItem('Category 4');
panel.add(lb);
var button = app.createButton('OK');
var handler = app.createServerClickHandler('click').addCallbackElement(panel);
button.addClickHandler(handler);
panel.add(button);
app.add(panel);
doc.show(app);
}
if (response == sh.Button.CANCEL)
{
sh.alert("Canceled", "The action is canceled", sh.ButtonSet.OK)
}
}
function click(eventInfo) {
var app = UiApp.getActiveApplication();
// get category that user chose
var value = eventInfo.parameter.myLbName;
var doc = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("items_with_category");
var RevenueItem = Browser.inputBox("Copy paste the name of the revenue item from the QB report:");
var COSItem = Browser.inputBox("Copy paste the name of the COS item from the QB report:");
var Client = Browser.inputBox("Copy past the client from QB report:");
var RevAcct = Browser.inputBox("Revenue Account Code (eg. 4001):");
var COSAcct = Browser.inputBox("Revenue Account Code (eg. 5001):");
var lastRow = doc.getLastRow()+1;
//doc.getRange(lastRow,1).setValue(value);
doc.getRange(lastRow,1).setValue(COSItem);
doc.getRange(lastRow,2).setValue(RevenueItem);
doc.getRange(lastRow,3).setValue(Client);
doc.getRange(lastRow,4).setValue(value);
}