简体   繁体   中英

Keeping data private in a Google spreadsheet while providing an edit dialog with apps script

I have an interesting problem to solve, and I'm tired of beating my head against the wall. Let's see if the good ol' Stack community can show me a good way to a solution.

  • I am using a Google Form for registration for an event. Data is collected into a spreadsheet. So far, so good.

  • While people enter the event, I will have registration clerks with laptops connected to the spreadsheet. They will locate the person in the spreadsheet when they come in, to check off that they showed up. Again, all is peachy.

  • Now the fun part: I want the registration clerks to turn the laptop around with the registrant's data pulled up in a small, standalone view. The issue is that I want the other registrants' data to be private.

  • I have gotten a small apps script to work for this, but the other registrants' data is still visible behind the popup in the spreadsheet.

  • I tried things like using background color to redact data, hiding rows, etc., but there will be many clerks working with the same sheet--so I'm guessing that will hinder others that are trying to perform the same function with another registrant.

  • My next thought was to use a standalone apps script web app to handle this, but I need to get the selected row from the spreadsheet to pass along to it. It seems like window.open is a no-go, so I think I'm back to square one.

I've exhausted all brainpower here, so any (and I do mean ANY) help is greatly appreciated.

I think the dumb solution that will probably work best is to just make the popup box large and ask users not to hit "OK" when they are done verifying data.

Thanks!

Do this: use a menu to bring up a dialog. The dialog shows just an anchor url to your webapp with url parameters that indicate the selected row. Clerk just clicks the anchor and the webapp opens with the right selection.

This may be an overly simplified solution but have the clerk select a different sheet (different tab) before running the script. This wouldn't work if the script depends on the contents of the active cell. But you could change it so it reads a specific column on the Form Responses sheet, like getRange("A2:A").getValues(), and populate a ListBox in a Formpanel with those values. It's been a while since I created stuff like this but I think it went like this:

function select() {
var doc = SpreadsheetApp.getActiveSpreadsheet();
var sheet = doc.getSheetByName("FormResponses");
var app = UiApp.createApplication().setTitle('My Application');
var form = app.createFormPanel();
var flow = app.createFlowPanel();
var lb = app.createListBox().setName('name');
var values = doc.getRange("A2:A").getValues();
for (var i=0;i<values.length;i++) {
lb.addItem(values[i],i);
}
flow.add(lb);
flow.add(app.createSubmitButton("Submit"));
form.add(flow);
form.addSubmitHandler(app.createServerHandler("submitFunction"));
panel.add(button);
app.add(panel);
doc.show(app);
}

function submitFunction(e) {
var name = e.parameter.name;
var app = UiApp.getActiveApplication();
var doc = SpreadsheetApp.getActiveSpreadsheet();
var sheet = doc.getSheetByName("FormResponses");
var data = sheet.getRange("A2:G").getValues();
for (var i=0;i<data.length;i++) {
if (data[i][1] == name) {
var result = data[i];
break;
}
}
for (var i=0;i<result.length;i++) {
app.add(app.createLabel(result[i]));
}
return app;
}

Then when you need to display the values you'd take the results from that ListBox.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM