How to connect Forms with JS Function returning an argument

  • 1 August 2017
  • 1 reply
  • 12 views

Badge

Hi,

I have some trouble with JS and Nintex Forms.
My starting position: List A with 2 columns: SessionName and SeatCapacity. Another list "Participant" selects the session from List A.
I had a JS function that delivers me the residual seats depending an what user selects. I put this function in the Settings/custom JS of the form.

e.g.

List A:  SessionName    SeatCapacity

            ----------------------------------------
           Session A           2

Participant:  userName    SessionName

                 ---------------------------------------

                 user01              Industry 4.0
                 user05              Industry 4.0
                 user06              Industry 4.0   <<--- and here is my sticky point, if user06 click on save, he must get an alert that session "Industry 4.0" is overbooked, and he can't save the form.

This is my goal. I'm verry new in developing forms. How do I address the js function from the "Save" button and get True or False or even the remaining seats ?

Any hint will be appreciate.

thx, Klaus


1 reply

Userlevel 5
Badge +14

you do not need javascript for this at all.

you just need to query Participants list with lookup() function filtered by session name. it will return all the items (already booked participants) that satisfy filter condition.

then you just need too count number of returned items with length() function.

something like described here

 

if you use this formula in validation rule comparing against capacity you can prevent submitting form if it is exceeded.

note however, that this kind of validation (regardless of whether made with js or lookup) is not bullet proof - if two or more participants are being booked to the same session at about same time it might happen that capacity is overbooked!

Reply