Form (Insert new record) validate off count field in a different object before submitting?

*Has anyone found a way to run a check during the submit form process off another object? As in I want to create a record in a registration object, but want to first check the count field in the shift object one more time.

We have a scheduling app with two objects, one that holds registration records of each instance of a staff registering for a shift (many → 1), and one that holds records of each shift (1-> many). The shift records can connect to more than one registration record. There is a count field in the shift object that is counting the number of records connected to it from the registration object.

We’re having trouble stopping folks from creating a registration record when there are no longer any spots left (count field in shift object is at 0). The view for the submit button on the form to create a new record is hidden by a page rule if the count field is at 0, however, if two staff open the page at the same time, the registration button will appear for both of them and both are then able to create a new registration.

Thanks for the HELP! :slight_smile:

Hi Lauren,

In your scenario you have a page rule hiding the submit button if the count is zero, but if you have two or more people booking at the same time it would let them make the booking for all parties, thereby taking your booking to a minus number.

This sounds like it would require some JavaScript to query the current count if the first person has submitted and the table has updated the rule to zero before the second person has submitted their form.

I am not a coder but there are some great guys on the expert partners directory that I’m sure could assist. Kelson Erwin is active on the forum and seems to have a very high level of technical brilliance with code.

Another, possibly less than satisfactory solution, would be to use Integromat to lookup the value of bookings available after each submission, and if less than zero lookup the last booking and email the customer to say that it is now over subscribed but they will be on a waiting list?

I appreciate that it would be cleaner if the user got a message on form submission stating that the event has now become fully booked while they were in progress. This is not a solution you could achieve with Knack built in. :disappointed_relieved:

Thanks for your response @CarlHolmes :slight_smile: Yes, you got the work flow exactly correct. I was worried it might not be achievable with just the built in (I’ve been trying for days). JS it is! I’ll check out the expert partners and see what we can come up with as my experience with JS is intermediate, but would take a while to dust off.


I’m glad my help was of no help :grin: At least you have eliminated it as built in Knack function :white_check_mark:

1 Like

Yes, thanks! I’m going to try playing with the JS examples I just found in the Knack docs too - JavaScript & jQuery Examples
Maybe I’ll get lucky :woman_shrugging:

1 Like

Hi Lauren,

This will require some custom code and the use of the Knack API.

Here are the steps to doing this with Javascript:

  1. When the form is first loaded disable the submit button with the disable html attribute. Do this on the view render event.
  2. On the view render send a GET request using the Knack API. You can do this with jQuery’s ajax. Be sure to use the view based request so that you do not expose your API key. If you are validating that only 1 record exists, send filters in with your request with the shift id. You might want to set up a hidden page that is only accessible to logged in users for this request. I like to set up a page called ‘API LOGIN’ that I only use for API work.
  3. Now you will have the JSON response from Knack. From here you will see a JSON property that displays the number of records. Add a conditional to the code where if the total records === 0 you will enable the button. If it’s > 0 you can do something else, or just keep the form disabled.

If you would like assistance setting this up, my company specializes in extending Knack’s functionality with custom code. We could probably get this built for you very quickly. Here’s my contact info:


Hi Lauren, I told you that Kelson was a whizz with code. You’ll not go wrong with reaching out to him to get this built if you can’t do it yourself.

I hope your post on the forum has helped you reach a speedy solution. Hopefully I’ll be able to help you on another (nocode) Knack query in the future.

1 Like

Thanks for all the details @Kelson! I really appreciate it. I’m going to give it a shot, if only to brush up on Javascript.

1 Like