Jump to content
  • 0

Limit the number of search by user?


DonettaMartins

Question

Hello,

I have set up a search form with Caspio.

Lets assume there are 2 types of users: those who pay and those who use the service for free.

 

Is there any way to limit the daily number of searches which the free user can run (say to 3 or 5 searches per day), while the users who are paying can run as many searches as they want daily,

 

Thanks for your help !

 
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hello,

This is a possible worflow for that objective.

first, both payers and non payers should be authenticated before search so we can track if the current user is a payer or not. I suggest that on the table which hold the user info, set a checkbox field there to differentiate them.

 

second, we will have to separate the search form to the results page of your data-page, you may refer to this article on how to. https://howto.caspio.com/tech-tips-and-articles/tech-parameters/how-to-separate-search-page-and-results-page-into-two-different-webpages/

However, we will not fully copy that step, we will modify it for a bit. I suggest that you do the the following instead.

1) duplicate your table which you use as a data source for this report datapage. name the duplicate whatever you like.

2) add some extra fields to your fields on the duplicate. a timestamp field upon insert and a field which is compatible to hold the id of the current user. (probably a text 255)

3) create a submission form using the duplicate table, Make sure to include the field for holding the Id. set this field to hidden with the id of the current user as a default value.

4) create a virtual field on the submission form to. set it to calculated value after that, we will use an SQL code to check how many  records are submited by the current user by the current date.

select count ([@field:IDfield]) from duplicate_table_ where DateDiff(day, SysUTCDateTime(), [@field:date]) =0;

* note that [@field:IDfield] and [@field:date] shall be replace with the ID field and timestamp  you just added on the duplicate table

5) create another virtual field and set it again to calculated value. this time, we are going to create a condition statement if the user shall be allowed to search or not.

Case

when [@field:payer] = 1

then *URL of your report datapage plust the other fields as a parameter*  

when targer.[@virtual1] < 3

then *URL of your report datapage plust the other fields as a parameter*  

Else www.somewhereelse.com

end.

6) Set your submission form to redirect to another website upon submit. use the URL your virtual field 2 as the source for its URL


7) last, you just have to set your report datapage to be filterd by external parameters.

 

The codes may not work but I hope you get the idea. 

 

 

Link to comment
Share on other sites

  • 0

Just an update.

As for the workflow I provided above, you are not collecting the values that are being used for searching since we are only using a dummy submission form filled with virtual fields. However,  if would also be nice if we will collect those values so we can generate later what are the most search records on your reports.

Anyway, if you happened to collect them, you can simply turn the field you are using on the step#5 to "Required" then use this formula instead.

Case

when [@field:payer] = 1

then *URL of your report datapage plust the other fields as a parameter*  

when [@virtual1] < 3

then *URL of your report datapage plus the other fields as a parameter*  

end.

 

for this case, if all conditions is falls, the field will remain as blank. however, since it is a unique field. it will not accept blank values this is will prevent submission. You'll just have to change the error message on the localization.

 

hope it helps,
quack

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...