You are viewing limited content. For full access, please sign in.

Question

Question

Runtime creation of Form Fields

asked on April 9

Good Day,

 

I have a scenario where I need the fields that are displayed to be variable. Now, I know that I can add all the fields I want to the form and then hide or display based on previously selected values. The problem I have is that in our case there could be over 80 or so fields and more can be added over time.

 

Basically, what I want to try and achieve is to add the fields at runtime based on a specific selection value. These would be read from a table and added. The scenario is I have 40 or so Job Titles and each would have a bunch of questions to be answered when a candidate applies for a position. So, based on the Job Title the questions related to that Job Title would be displayed on the form.

 

It has to be totally dynamic and done at runtime.

 

Alternatively, if that's not possible I assume I could load the questions into a Table Field, which is easy to achieve. However, the column where the user enters their answer needs to be formatted differently per question e.g. for Row 1 The answer cell might be numeric, Row 2 the answer cell might be a Yes/No etc. Can that be achieved?

 

Does anyone have any ideas how I could achieve this?

0 0

Replies

replied on April 9

Use a SQL table to populate a collection with each row containing the question and a field to gather the answer. The SQL table would need to have columns for job title, question, and possibly field type to allow conditional display of the corresponding field type. This way, you only need to define the conditions for the field types for a single row of the collection based upon the results of the SQL query by job title. I'd go a step further and make it by a job ID number rather than job title, since job titles can change.

Example data:

JobID,JobTitle,Order,Question,Type
1,'IT Analyst',1,'What is the Internet?','singleline'
1,'IT Analyst',2,'Follow-up multiline question','multiline'

Example collection would contain the fields Question (read-only from SQL lookup), Type (read-only from SQL lookup), SingleLine (for response), MultiLine (for response),etc.. The rule for displaying SingleLine would be hidden and not required when Type does not equal 'singleline'. Similarly, the rule for displaying MultiLine would be hidden and not required when Type does not equal 'multiline'. From your SQL lookup, you can sort by the 'Order' column to reliably control the order they are displayed.

2 0
replied on April 9

Your answer makes this question make much more sense haha. You could take it a step further and support radio/checkbox fields with a subsequent lookup call for each row and a "question_choices" table if you have a question id column in your example too.

It will slow the form down a little bit, but you could toss a progress bar over the table while the lookups are still firing

1 0
replied on April 9

Are the jobs being applied to a part of that table? If so, I would just use a collection instead as it allows better formatting for all of the fields you would need. 

Regardless, this  might help. If you nest fields within a section you can just apply that show/hide field rule to the section itself. That way in the future, adding or removing fields from that section will automatically apply the show/hide rule.

For Example, user selects "Job #1" and Field rule Show "Job #1 Section" when "Job Applying To" is "Job #1"

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.