Customize a Knack Form with a Record

I have developed some Javascript that you may find useful, and I am happy to share it. You can find the code at https://bit.ly/4fAxYph. I will describe what it does in my context, and hope you will find it applicable in yours.

I am using Knack to develop a Learning Portal where students can register and review courses being offered. This application has student constituencies of many types, and the portal registration form for a student needs to be customized to fit the situation. To accomplish this, I have set up a mapping file that specifies what fields to make required, what fields to hide, whether include the password or not, what fields to pre-fill with what values, and what tags to create for the student (tags are used to match students to courses, i.e. to filter the grid view of courses - which is more JavaScript code if you’re interested).

The whole process is driven by a URL query parameter: ?track=trackname. The mapping file contains a record for each trackname. The code is somewhat specific to my application, but I think anyone interested in the concept of having one form that can appear in many different ways will find it fairly easy to adapt.

The form replaces the native User Registration page, because I have more control over a regular form, and it seems to do everything a native User Registration form would do, i.e. creates an account, tags the User Role, etc. The page includes two views: a hidden view of the mapping records and a view that is the form itself, after the customization has been applied. So I only need one form on one student registration page, and I can create any number of customizations, which are controlled by where the user came from.

It represents a lot of work. I hope others will find it useful, and I’d be happy to answer any questions. Other code I have not provided includes getting the URL query parameters into a global variable, and the filtering itself when the course grid is shown to a particular student. I will share them if anyone is interested. This form customization technique is the part I thought would be of the most generally interesting and useful.

I developed this code with the help of Claude 3.5 and GPT 4-o1. This can be a long, frustrating process, but I find it amazing how much I have accomplished this way. My coding skills are decades out of date. But my understanding of data and coding logic partnered with AI’s ability to crank out code makes a powerful team.

2 Likes