# Discount coupon system

**URL:** <https://community.thunkable.com/t/discount-coupon-system/2935016>\
**Category:** Questions about Thunkable X\
**Created:** [April 8, 2024, 11:13am UTC](https://community.thunkable.com/t/discount-coupon-system/2935016 "2024-04-08T11:13:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![luiz.primaz2ddpyu](https://avatars.discourse-cdn.com/v4/letter/l/e9a140/32.png) [@luiz.primaz2ddpyu](https://community.thunkable.com/u/luiz.primaz2ddpyu)\
**Post date:** [April 8, 2024, 11:13am UTC](https://community.thunkable.com/t/discount-coupon-system/2935016/1 "2024-04-08T11:13:55Z")

</div>

Is there any way I can create a system that will check if there is a line with a specific value in Data Sourcers? Explaining: I wanted to create a coupon system, when placed in a Text\_Input I wanted it to check if the coupon existed, if it existed it would go to another screen with the value of the coupon saved, if it did not exist I wanted a message to appear warning that the coupon is invalid.

---

<div class="post-metadata">

**Author:** ![steve\_synopsis](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@steve\_synopsis](https://community.thunkable.com/u/steve_synopsis)\
**Post date:** [April 8, 2024, 11:36am UTC](https://community.thunkable.com/t/discount-coupon-system/2935016/2 "2024-04-08T11:36:19Z")

</div>

Yes, you can but what data source do you plan on using?

---

<div class="post-metadata">

**Author:** ![luiz.primaz2ddpyu](https://avatars.discourse-cdn.com/v4/letter/l/e9a140/32.png) [@luiz.primaz2ddpyu](https://community.thunkable.com/u/luiz.primaz2ddpyu)\
**Post date:** [April 8, 2024, 11:43am UTC](https://community.thunkable.com/t/discount-coupon-system/2935016/3 "2024-04-08T11:43:19Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/8/3858003d946fd7c5674b9841ad212447594c9506.png)

---

<div class="post-metadata">

**Author:** ![steve\_synopsis](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@steve\_synopsis](https://community.thunkable.com/u/steve_synopsis)\
**Post date:** [April 8, 2024, 1:10pm UTC](https://community.thunkable.com/t/discount-coupon-system/2935016/4 "2024-04-08T13:10:12Z")

</div>

You would set up your table with cells similar to this -

couponId, discountValue, etc, etc.

Unfortunately, SQL type searches are not supported on the local datasource, so you would have to retrieve all of the couponIds and iterate through a loop comparing the Text\_Input to the cell value.

If there is a match, then you move to the next screen. If not, you display an error.

If you use Airtable, that supports a function called filterByFormula which will search the database and return either 1 result (in the case of a match) or no results (no match). However, this method requires a little more legwork as the result is returned in a JSON format and more blocks will be involved.

If you are new to Thunkable, I would recommend the first option just to make sure that you can get the app working the way you would like and then possibly more to Airtable which is a more flexible solution.

Note however, that the Airtabe requires that the device has internet connectivity.

Steve

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [April 8, 2024, 7:19pm UTC](https://community.thunkable.com/t/discount-coupon-system/2935016/5 "2024-04-08T19:19:04Z")

</div>

> [@steve\_synopsis](#):
>
> Unfortunately, SQL type searches are not supported on the local datasource, so you would have to retrieve all of the couponIds and iterate through a loop comparing the Text\_Input to the cell value.

The best way to do this is to use the Find First Occurrence block, as mentioned [here](https://community.thunkable.com/t/thunkable-and-returns-a-corresponding-value-from-my-sheet/2446081/2).

That block returns a 0 if the search term is not found and a positive integer corresponding to the row number it was found in if it exists.

---

<div class="post-metadata">

**Author:** ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)\
**Post date:** [April 8, 2024, 7:29pm UTC](https://community.thunkable.com/t/discount-coupon-system/2935016/6 "2024-04-08T19:29:35Z")

</div>

if your table is static and used as reference table (input only, no update), then you can use google sheet and apply the techniques in this article to use SQL-like queries to lookup any record.

> [@Quiz App using google sheet via google's visualization API Query Language (instead of Data Source)](https://community.thunkable.com/t/quiz-app-using-google-sheet-via-googles-visualization-api-query-language-instead-of-data-source/1866448):
>
> i’ve just recoded my earlier quiz app which used airtable as datasource into a new version using google sheet as source of the quiz but NOT as a data source. Instead i’m using Google’s Visualization API Query Language to read the worksheet (see this recent [discussion](https://community.thunkable.com/t/get-data-from-google-sheets-without-using-the-data-source-blocks/1863069/9) in the forum ). It’s a different approach for working with google sheets, but i like it! below is the contents of my worksheet. ( Note - in order to use the query language, the worksheet must first be shared such that anyone wit…

---

<div class="post-metadata">

**Author:** ![pacecode](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/pacecode/32/209017_2.png) [@pacecode](https://community.thunkable.com/u/pacecode)\
**Post date:** [April 9, 2024, 9:58am UTC](https://community.thunkable.com/t/discount-coupon-system/2935016/7 "2024-04-09T09:58:53Z")

</div>

![Screenshot 2024-04-09 at 3.28.06 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/c/5cd37800e8ab21eb75ba776c17a54a8eea0361f2.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [July 8, 2024, 9:59am UTC](https://community.thunkable.com/t/discount-coupon-system/2935016/8 "2024-07-08T09:59:26Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
