Set & track quantity limits

In Cognito Forms, you can set quantity limits and track quantities for many field types. Quantity limits are useful for product orders, ticket sales, signups, reservations, surveys, and any other scenario for which there’s a limit to the number of times a specific value may be selected or entered across all submitted entries for a form.

Quantities are tracked for each unique value entered for the field, such as each email address, or each choice field selection. Quantity limits are updated and enforced when selections are made, and then again before forms are submitted. If the limit is exceeded, an error message is displayed. Quantities are only counted for submitted entries, not incomplete or deleted entries. Every time a quantity is updated, you can review the entry audit log to see the new quantity and when it changed.

Setting limits

Supported field types for quantity limits include:

  • Textbox - Single Line
  • Choice - Dropdown or Radio Buttons
  • Yes/No
  • Date/Time
  • Email, Phone, or Website
  • Calculation - Text, Yes/No, Date, and Time

To set a quantity limit, select a supported field type and specify the Limit Quantity option in the field settings.

Limiting quantity options.

  • No Duplicates – Limit the quantity allowed to just one. Once your limit is set, you can write a custom error message to display when the limit is exceeded.
  • Specific Quantity – Specify a quantity limit greater than one. This value can be either a constant integer, or an integer calculation.
  • Never – Quantity limits are not enforced. This option is set by default.

Choice fields

Quick Tip

Quantity limits can be specified for Choice fields set to the Radio buttons or Dropdown types. Changing a choice option label (“Product 1”) will reset the quantity available for that choice option.

For Choice fields, you can first select Limit Quantities from the Choice options in the field settings. Then, specify a quantity for each choice option. Leaving a quantity blank will ensure that quantity limits are not enforced for that choice option. After you set your choice quantities, you can enter a custom error message to display when the limit is exceeded.

Just like with Assign Prices and Assign Values, when Limit Quantities is selected for a Choice field, the quantity of the selected choice is available within calculations as FieldName_Quantity. Also, if the assigned quantity is used to calculate the quantity limit for another field, quantity limits will not be validated for the Choice field itself, which is useful for more complex quantity limit scenarios.

Specify quantity

When a Choice field is set to the Radio Buttons or Drop Down type, you can select this option to map a quantity value to the Choice field. The mapped quantity field can be either a Number (Integer) or Calculation (Number, Zero Decimals) field on the form.

If payment is enabled, the selected quantity will automatically be multiplied by the price of the selected choice option to determine the total price in the payment block. If quantity limits are enabled, the selected quantity will be applied to the quantity remaining.

Map the Specify Quantity option to a Number or Calculation field on the form.

Lookup fields

Lookup fields allow you to “look up” data from another form’s entries. Essentially, you can use the source form to manage your data (such as a product inventory or a list of event timeslots), and then use a Lookup field on a separate form to reference the data as needed.

Similarly to Choice fields, you can set quantity limits for each option in the Lookup field. In this case, the quantity available is connected to a Number field on the source form instead. In addition to quantity limits, you can use the Lookup field to filter choice options based on dates, times, or other custom criteria.

QuantityLimits3.png

Yes/No fields

For Yes/No fields, quantity limits only apply to Yes responses. This is useful for registration forms or other scenarios where form submitters can opt into an event (like a dinner) where a limited number of spots are available. Unlimited No responses are allowed.

Calculation fields

While Calculation fields support quantity limits just like other fields, they have special capabilities that make it possible to implement complex quantity limit scenarios. When you enforce quantity limits on a hidden calculation field (when Show This Field is Internally or Never), the quantity limit error message will automatically appear under the fields referenced by the calculation for the field. This makes it possible to enforce multi-field combination limits, like rooms on a specific date, or ticket types for a specific performance, and show quantity limit errors on the fields that must be changed to correct the problem.

Calculations

In addition to automatically limiting quantities and showing errors, you can also access the quantity limit, the quantity remaining and the quantity used for the selected/entered field value within calculations. These calculation properties are named as follows:

  • FieldName_QuantityLimit: The quantity limit for the current field value.
  • FieldName_QuantityUsed: The amount of times the current field value has been specified, including all submitted entries and changes reflected in the current entry.
  • FieldName_QuantityRemaining: The difference between the quantity limit and the quantity used. This value will be negative when the limit has been exceeded for a given field value.

For submitted entries, these quantity limit calculation properties reflect the values they had when the entry was submitted, and only update when the entry is edited. This allows you to see what the quantity limit was at the time of submission in situations when the limit is later changed to something else. Please keep this in mind when viewing submitted entries and calculations that rely on these quantity limit calculation properties.

Scenarios

Common uses of quantity limits include:

1) Unique Email Address

Limit people to just one submission per unique email address:

  1. Add an Email field to capture the email address of the form submitter
  2. Set Limit Quantity to No Duplicates
  3. Write a custom error message (ex: “Only one submission per email address is allowed.”)

Limiting to one unique email address.

2) Unique IP Address

Limit the number of submissions per unique IP address:

  1. Add a Calculation field to look up the IP address of form submitters
  2. Set Calculation to =Entry.Origin.IpAddress
  3. Set Show This Field to For Roles > Internal
  4. Set Limit Quantity to Specific Quantity
  5. Set Quantity to the number of submissions allowed per IP address, such as 2
  6. Write a custom error message (ex: “Only two submissions are allowed per person.”)

Limiting to unique IP address.

3) Limited Use Discount Codes

This approach will only validate the discount code, letting people know if the code is invalid or has been used up. A separate Price field calculation will be required for payment forms to apply a discount based on the selected discount code.

Limit the number of times a discount code can be used:

  1. Add a Textbox field to capture a limited use discount code
  2. Set Limit Duplicates to Specific Quantity
  3. Set Quantity to =if DiscountCode = "SUNDRIED" then 20 else if DiscountCode = "SCOTFREE" then 10 else null
  4. Write a custom error message (ex: “This discount code has expired!”)
  5. Set Show Custom Error to When
  6. Show the custom error when DiscountCode is filled out and DiscountCode_QuantityLimit is not filled out
  7. Write a custom error message (ex: “Invalid discount code!”)

If you have lots of discount codes or need to constantly add and remove discount codes over time, the following additional steps will help makes things easier to maintain:

  1. Add a Choice field to track available discount codes
  2. Add Choices for each available discount code
  3. Select Limit Quantities to specify a quantity for each discount code
  4. Select Assign Prices or Assign Values to enter prices/percentage discounts for each choice value
  5. Set Default Value to =DiscountCode
  6. Set Show This Field to Never to hide this list of available discount codes
  7. For the discount code Text field, set Quantity to =AvailableDiscountCodes_Quantity
  8. Write a custom error message (ex: “Discount code quantity exceeded”)
  9. Add a Price field to calculate the discount based on the assigned prices. Set the amount to =if DiscountCode = AvailableDiscountCode then -AvailableDiscountCode_Price else 0

Limited use discount codes.

4) Signup Limits

Limit the number of attendees to an event:

  1. Add a Yes/No field for users to sign up
  2. Set Limit Duplicates to Specific Quantity
  3. Set Quantity to a specific number of attendees
  4. Write a custom error message (ex: “The pre-event dinner has reached capacity!”)

Sign up limits.

5) Product Inventory

Limit the number of times a specific product may be selected based on available quantity:

  1. Add a Choice field containing a list of products
  2. Select Limit Quantities and specify a quantity for each product
  3. Write a custom error message (ex: “Out of Stock.”)

Limiting product inventory.

6) Ticket Sales

Add a Choice field to select a performance to attend (Friday night, Saturday matinee, Saturday night):

  1. Add a Choice field to select the ticket class (premium, standard, basic)
  2. Select Limit Quantities to allow quantities to be specified for each seat type
  3. Specify a Quantity for each seat type
  4. Add a Calculation field to limit available tickets for each performance
  5. Set Calculation to =Performance + "-" + SeatType
  6. Set Show This Field to For Roles > Internal
  7. Set Limit Duplicates to Specific Quantity
  8. Set Quantity to =SeatType_Quantity
  9. Write a custom error message (ex: “Sorry, there are no more seats available for the selected ticket class.”)

Limit quantities based on the number of seat types available.

7) Timeslot Limits

Limit the number of attendees to a class on each unique date the class is offered:

  1. Add a Choice field containing a list of classes
  2. Add a Date field for users to select a date to attend class
  3. Add a Custom Error to the Date field limiting date selections to days that the selected class is available, such as Tuesdays and Thursdays
  4. Add a Calculation field and use the following expression:
  5. Set Calculation to =Class + Date
  6. Set Show This Field to For Roles > Internal
  7. Set Limit Duplicates to Specific Quantity
  8. Set Quantity to a specific number of attendees, like 20
  9. Write a custom error message (ex: “Class is full on this date.”)

Limit the number of slots available on a specific date.

8) Limit Form Submissions

Limit the total number of submitted form entries:

  1. Add a Calculation field to the bottom of your form. Label it ‘Registration’ (or something similar)
  2. Set the calculation to a static value (ex: “test”)
  3. Set Quantity Limits to Specific Quantity
  4. Set Quantity to the number of entries you would like to receive, such as 20
  5. Write a custom error message (ex: “Registration is full!”)
  6. Set Show This Field to Never

This calculation will limit the total number of submitted registrations and show an error message to anyone trying to view/submit the form once registration is full. If you later delete a registration, extra registration slots will automatically open up.

Limiting form submissions.

Frequently Asked Questions