Tab showing based on choice

Hi everybody, I’m working on an app for events, I’d like to allow people load pictures and I want to allow that feature only to the people who accept a privacy statement and a responsibility statement for what they upload. Is there a way to set such condition?

Thanks.

Obviously you need to start with requiring email/pin log in. Take a look at this tutorial: https://docs.glideapps.com/all/guides/intermediate-techniques/per-user-data

So once you get to the point where each user can only see their own information based on the email filters described above, you would have a Form Button on their “Profile” page. Create a Text field with your privacy statement and responsibility statement and include verbiage that says by uploading they agree, and have the picture upload component on that page as well. This way each time they upload a picture they are shown the privacy and responsibility statement.

1 Like

I like @George_B idea. I would consider an “I Agree” checkbox. The only downside is that for some reason, you can’t mark the checkbox as required.

1 Like

Hi George, thanks for your reply. Actually I don’t want to limit visibility, I’m trying to find a solution on sheet side maybe a script to delete rows if check box is not checked in the app. As I have a limited scripting experience, do you know if there’s a way to trigger the script as a row is added?

Thanks

I simple solution without a script could be to have an image column and a checkbox column. If the checkbox is TRUE, then fill a second image column with the value from the first image column. This won’t delete the records, but you can use just the filled image records in the second image column elsewhere in your app. If you need the records to go away, then a script would be the ideal solution.

2 Likes

I would say that a script is your only option if you want to make sure that there are no pictures for anyone who doesn’t have the true/false flag (true = agreed to the terms). The pictures would be stored in a Pictures tab and along with all the other information you want to have about them would the the email of the user who uploaded them. A script would be created to scan that sheet and look up the email in the users’ sheet, then look at the flag and if not true, delete or somehow disable the row.

Look up a few tutorials on scripting and once you have some basic knowledge post questions about what you are stuck on.

George

1 Like

I found the script below, it seems working fine in a test sheet but, if I copy the script in the sheet linked to an app, it doesn’t work. Moreover the trigger I set “on changing” the sheet doesn’t fire the script. Any help?

Thanks in advance.

function deleteRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
var values = rows.getValues();

var rowsDeleted = 0;
for (var i = 0; i <= numRows - 1; i++) {
var row = values[i];
if (row[4] == ‘FALSE’) {
sheet.deleteRow((parseInt(i)+1) - rowsDeleted);
rowsDeleted++;
}
}
};

Number 1, the script when run will delete rows in the “Active” sheet. So depending on which sheet had focus it will preform the logic on that sheet. You really should be specifying which sheet it should be doing it on. Use:

  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("Sheet1");

Edit: As long as you add the Google App trigger to call the function it should trigger.

@George_B are you sure about the onchange trigger not working with the sheet closed? I swear I’ve seen this work (at least I’ve never had an issue with it not working). I swear I’ve tested it and it worked, but it’s also not something I use much either. Not saying I’m right…just trying to verify if it’s still the case.

The attached post is just a reference to when I had tested it with the sheet closed, so I know I’ve done it recently.

I’m guessing I had the prior conversation about importrange() in my mind. Thanks for the brain check.

I could still be wrong. I’ve seen conversations of mixed results with onchange. Not sure if a lot of people have tried it for me to know for sure.

I confirm it does work if set up properly.

I wrote this stripped down test spreadsheet and Glide App. Only 2 sheets. Make a copy of it if you want. There is a script attached to the spreadsheet with a function that increments cell A2 on the Counter sheet. If there is an OnChange Trigger set up you will see that cell value change every time there is a spreadsheet change.

Add a record or edit an existing one and you will see the counter update. There is a delay as Glide does not update the spreadsheet instantly (up to 3 min, but usually less)

Here is the app:
https://dvsoj.glideapp.io

1 Like

@George_B Glad to see it’s working. Now I feel a little better about recommending the onChange trigger. :+1:

1 Like

Thanks @George_B and @Jeff_Hager , I’m going to try your solution in the weekend, I’ll let you know if it works for me.

1 Like

Thanks for your advices, the script now works great. if you want, you can try it to the following link demoselvareale.glideapp.io On the tab “Carica Foto” you find the check box “Assunzione di responsabilità”, if you don’t check the box the script erases the row in the sheet.
As you can argue, the app is a benchwork for testing ideas before delivering in production app.