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

Question

Question

Auto-populate Forms field list choices using "LUP" table

asked on March 15, 2016

Hi - I would like to populate a Forms field with list choices from a matching field in the repository.  I understand that you can use a data source lookup to query the "LUP" table for the choices.  First attempt gives all list choices, i.e. the choices from all list field regardless of "prop_id".  I was able to get a workable solution by creating a second Forms field (hidden) and hardcode the prop_id, then use that value in a "When" condition while defining the Lookup Rules.

My question is: do you have to create that second (hidden and hardcoded) prop_id field for every Forms field that you want auto-populated, or is there a simpler or more elegant way to define the Lookup Rule (or something else) and reach the same end effect?

Thanks!

0 0

Answer

SELECTED ANSWER
replied on March 16, 2016

Hi Steven,

The idea behind lookup rules is really to fill one (or more) field(s) based on the values of one (or more) other field(s). If no condition field is specified, the behavior is indeed to simply fill every value from the database. [Help File entry on lookup rules] So to filter only a portion of the table, I believe that what you are doing with a hidden field setting the prop_id field is the way to go.

I'm not sure that I would necessarily call the method "inelegant"; in many forms (that is, HTML forms including those not created using Laserfiche Forms) hidden input fields are used in this very way to communicate certain metadata to whatever script will be processing the form; there's a discussion on StackOverflow on this topic, if you're curious.

Hope this helps!

0 0
replied on March 16, 2016

Thanks, James - I appreciate the reply and the other thread reference.  I will continue to use the hidden field solution, had just been hoping that I could include the prop_id value in an attribute to the lookup rule, thus having a single step solution.  Good to have validation that this is the preferred method.

Thanks again, .... Steven.

0 0
replied on March 16, 2016

You're welcome Steven,

If this is the only form where you'll be looking up information from the lup table, and you'll only be performing a lookup based on a single prop_id value, you could also create a stored procedure which selects from the table where prop_id = whatever, and use that as the data source instead. Essentially the filtering would be done before Forms accesses the data.

I don't know if that would be considered more or less elegant; the advantage of using the hidden field would be that a Forms admin who didn't necessarily have rights to modify a stored procedure in SQL would still be able to change the hard value if necessary. Also, depending on the size of the table, there may be a greater delay in running the lookup if using a stored procedure (as it will take time for it to execute before the lookup happens).

0 0

Replies

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

Sign in to reply to this post.