# Tab showing based on choice

**URL:** <https://community.glideapps.com/t/tab-showing-based-on-choice/1607>\
**Category:** Ask for Help\
**Created:** [November 2, 2019, 9:44am UTC](https://community.glideapps.com/t/tab-showing-based-on-choice/1607 "2019-11-02T09:44:05Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![thebepps](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thebepps/32/2956_2.png) [@thebepps](https://community.glideapps.com/u/thebepps)\
**Post date:** [November 2, 2019, 9:44am UTC](https://community.glideapps.com/t/tab-showing-based-on-choice/1607/1 "2019-11-02T09:44:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![George\_B](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/george_b/32/534_2.png) [@George\_B](https://community.glideapps.com/u/George_B)\
**Post date:** [November 2, 2019, 11:13am UTC](https://community.glideapps.com/t/tab-showing-based-on-choice/1607/2 "2019-11-02T11:13:47Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [November 2, 2019, 5:10pm UTC](https://community.glideapps.com/t/tab-showing-based-on-choice/1607/3 "2019-11-02T17:10:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![thebepps](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thebepps/32/2956_2.png) [@thebepps](https://community.glideapps.com/u/thebepps)\
**Post date:** [November 2, 2019, 5:11pm UTC](https://community.glideapps.com/t/tab-showing-based-on-choice/1607/4 "2019-11-02T17:11:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [November 2, 2019, 5:19pm UTC](https://community.glideapps.com/t/tab-showing-based-on-choice/1607/5 "2019-11-02T17:19:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![George\_B](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/george_b/32/534_2.png) [@George\_B](https://community.glideapps.com/u/George_B)\
**Post date:** [November 2, 2019, 5:31pm UTC](https://community.glideapps.com/t/tab-showing-based-on-choice/1607/6 "2019-11-02T17:31:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![thebepps](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thebepps/32/2956_2.png) [@thebepps](https://community.glideapps.com/u/thebepps)\
**Post date:** [November 6, 2019, 7:45pm UTC](https://community.glideapps.com/t/tab-showing-based-on-choice/1607/7 "2019-11-06T19:45:46Z")

</div>

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++;  
}  
}  
};

---

<div class="post-metadata">

**Author:** ![George\_B](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/george_b/32/534_2.png) [@George\_B](https://community.glideapps.com/u/George_B)\
**Post date:** [November 6, 2019, 9:44pm UTC](https://community.glideapps.com/t/tab-showing-based-on-choice/1607/8 "2019-11-06T21:44:01Z")

</div>

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:

```auto
  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.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [November 6, 2019, 11:18pm UTC](https://community.glideapps.com/t/tab-showing-based-on-choice/1607/9 "2019-11-06T23:18:51Z")

</div>

@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.

> [@Time stamp update](https://community.glideapps.com/t/time-stamp-update/1382/12):
>
> I just tried it with one of my apps where I use a form button to create a new record. That triggers the onchange and runs the script to copy the value to another sheet, so as far as I can tell, it should work. An alternative would maybe be to split your switches into seperate sheets, set up relations to those sheets and create an inline list that links to each sheet. Then when you open up the list item, you can click on the pencil to edit the switch. That will allow you to use the Date/Time …

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.

---

<div class="post-metadata">

**Author:** ![George\_B](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/george_b/32/534_2.png) [@George\_B](https://community.glideapps.com/u/George_B)\
**Post date:** [November 7, 2019, 12:53am UTC](https://community.glideapps.com/t/tab-showing-based-on-choice/1607/10 "2019-11-07T00:53:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [November 7, 2019, 1:20am UTC](https://community.glideapps.com/t/tab-showing-based-on-choice/1607/11 "2019-11-07T01:20:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![George\_B](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/george_b/32/534_2.png) [@George\_B](https://community.glideapps.com/u/George_B)\
**Post date:** [November 7, 2019, 3:16am UTC](https://community.glideapps.com/t/tab-showing-based-on-choice/1607/12 "2019-11-07T03:16:35Z")

</div>

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](https://dvsoj.glideapp.io)

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [November 7, 2019, 2:52pm UTC](https://community.glideapps.com/t/tab-showing-based-on-choice/1607/13 "2019-11-07T14:52:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![thebepps](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thebepps/32/2956_2.png) [@thebepps](https://community.glideapps.com/u/thebepps)\
**Post date:** [November 8, 2019, 1:28pm UTC](https://community.glideapps.com/t/tab-showing-based-on-choice/1607/14 "2019-11-08T13:28:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![thebepps](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thebepps/32/2956_2.png) [@thebepps](https://community.glideapps.com/u/thebepps)\
**Post date:** [November 9, 2019, 10:20am UTC](https://community.glideapps.com/t/tab-showing-based-on-choice/1607/15 "2019-11-09T10:20:41Z")

</div>

Thanks for your advices, the script now works great. if you want, you can try it to the following link [demoselvareale.glideapp.io](http://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.

---

<div class="post-metadata">

**Author:** ![apertur.co](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@apertur.co](https://community.glideapps.com/u/apertur.co)\
**Post date:** [November 30, 2019, 9:30pm UTC](https://community.glideapps.com/t/tab-showing-based-on-choice/1607/16 "2019-11-30T21:30:25Z")

</div>

I don’t think the script comes over with the app. I copied the app, and the increment doesn’t work when it’s on my account. The Script Editor doesn’t show any existing scripts either.

---

<div class="post-metadata">

**Author:** ![George\_B](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/george_b/32/534_2.png) [@George\_B](https://community.glideapps.com/u/George_B)\
**Post date:** [December 1, 2019, 12:20am UTC](https://community.glideapps.com/t/tab-showing-based-on-choice/1607/17 "2019-12-01T00:20:35Z")

</div>

Interesting, I thought it would come across. Here is the code.

```auto
// create a Google App Trigger for this function
// go to Edit/Current project's triggers. Add an OnChange trigger that runs this function
// it will increment the value in sheet Counter cell A2 every time this function runs
function onChange() {
  var sheet = SpreadsheetApp.getActive().getSheetByName('Counter');
  var range = sheet.getRange("A2");
  var data = range.getValue();

  range.setValue(++data);
}

```
