Discount coupon system

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.

1 Like

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

1 Like

image

1 Like

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

1 Like

The best way to do this is to use the Find First Occurrence block, as mentioned here.

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.

1 Like

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.

1 Like

1 Like

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