Logo
For example "scheduled tasks"
Search
Info
Content
Category Navigation
  • 🎯  Solution Guides

  • Low Code Solutions

    Add "Tabs" to your app

    ID Target Link

    Use an address field to display a static street view thumbnail

    Turn your menu into a fixed menu

    Auto close mobile menu

    Display record information in a card

    How to add a back button to your app

    Add a collapsible accordion element to your app

    Code Snippets

    PHP Curl Create New Record

    PHP Get Records With Filters

    Google Scripts - Get record and create new records from connected table

    Save Tables and Fields into Spreadsheet

    Google Scripts - Export all records

    Webhook to save deleted records

    Send Messages to Slack

    Restrict Space and Force Uppercase in a Form

    Building Advanced Features

    Use Validation Rules to Ensure Unique Votes Per User

    Use Record Rules to Create an Audit Log

    Track current inventory with transactions

    Schedule Bookings and Prevent Double Bookings

    Create orders with multiple items and varying quantities

    2 Step Forms

    Unique Record Validation

    Restrict Editing Records to Record Owners

    Sum date/time field

    Duplicate Records

    Advanced App Customization

    How to embed a Tadabase page on another website

    Adding external fonts

    Custom Favicon

    Making apps mobile friendly

    Show date/time as a countdown

    Importing many images at once

    Adding QR Codes

    Adding charts to PDFs

    Customizing your app shortcut for mobile phones

    Animate parts of a page

    Design Customization

    Changing background colors

    Set background colors to the edge of a page

    Change the background of a column

    Add padding around a component

    Using an image as background for a page

    Adding a background image to a row, column, or component

  • Duplicate Connected Records

Categories
🎯 Solution Guides
Building Advanced Feat...
Use Validation Rules t...

Use Validation Rules to Ensure Unique Votes Per User

Validation Rules allow you to check the validity of data based on custom-defined conditions and disable a form from being submitted if your validation rules are met.

For instance, you can create a validation rule to prevent a form from being submitted when a user attempts to add a job with an end date that starts prior to the start date. 

Another instance where validation rules can be highly effective is with voting functionality.

If you have a Feature Voting Platform where users can vote on features, you would want to ensure that each user can only vote for each feature only one time. Users can vote for multiple features, but you want to ensure that they can only vote for each feature only once.

You can accomplish this by creating a validation rule to prevent the vote from being submitted if the logged-in Voter and the selected feature are both not unique. Meaning, if there is already an existing record of this logged-in voter voting for this specific feature, disable the form from being submitted and show an error display message of "You have already voted for this feature!"

Before we discuss how to create this validation rule, let's first discuss the data structure of this Feature Voting app so you can understand which fields to utilize within the validation rule.

Within the Data Builder, you would have three data tables:

  1. Users data table with users assigned to a Voter user role
  2. Features data table storing records of features
  3. Votes data table with two connection fields: one connection to the Features data table (each vote belongs to one feature) and one connection to the Users/Voters data table (each vote belongs to one voter). Within in the Votes data table you can also add fields such as Vote Name and Vote Occurred At.

Once you've built this data structure within the Data Builder, you can create the Voting form within the Page Builder for users to vote on features.

Within the Page Builder, add an Add Vote Form and within the Record Rules of this Add Vote Form, add a record rule to update this vote record and set the Voter to the Auto Logged User and the Vote Occurred At to the current date and time.

Now, when users/voters submit a vote on a feature, their vote record will automatically be updated to the name of the currently logged-in user as well as the current date and time of which the vote was submitted.

Since you are using record rules to auto-save the values of the logged-in voter's name and the current date and time, you can now remove these fields from the form as they will be automatically saved anyway once the form is submitted. 

Once you have added the record rule to the form to auto-save the logged-in voter's name and current date and time, you can now create the Validation Rule to prevent the form from being submitted if a voter votes on a specific feature more than once.

To create this validation rule, open the Add Vote Form component and select Form Rules > Validation Rules > Add New Validation Rule button. 

add-validation-rule-2.png

Then, create a validation rule to prevent the vote from being submitted if the Voter and selected feature are not unique. Select the Voter field and select "is not unique". Then select the checkbox for Check Additional Fields and select the Feature field to also check if the selected feature is not unique. When users attempt to submit a vote on a feature, this validation rule will check for an existing record of this logged-in voter and this selected feature. You can also create a custom error message should this validation rule be met, such as "You have already voted for this feature!"

voter-valid-rule.png

Now, when a user attempts to submit a vote for a feature that is not unique for this voter, the form will not submit and the above error message will display. As you can see in the Votes table component below, logged-in voter Bob Lowell has already voted for the plugin feature and therefore can not vote for this feature again.

add-vote.png

 

How did we do ?

Previous Section
Code Snippets
Next Article
Use Record Rules to Create an Audit Log
Back to top
API
100% Operational
Apps
100% Operational
Builder
100% Operational
Overall Status
100% Operational