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

Question

Question

Populate Checkbox and Radio from Lookup in Self-Hosted Forms

asked on January 2, 2024 Show version history

I'd like the ability to populate Checkbox and Radio Button choices from a lookup, especially now that we can view both field types as drop-downs (Amazing feature!). For my specific case, I have a drop-down from a lookup to select the Department. I then have a single line with matching Divisions suggested from the same lookup table. Users have to manually type each division if they want to add multiple.

I've seen a lot of discussions with possible JavaScript options, but those wouldn't help with the modern designer.

1 0

Replies

replied on January 8, 2024

Well...wonderful. I tested on cloud. I just tested it on on-prem and there is no out of the box way to fill radios or checkboxes from a database lookup. 

And looking at some other posts on Answers it doesn't appear it's available for on-prem. 

I did, however, see quite a few folks figure out a way to do it with tables/collections and js. 

I am sure this can be figured out, it's just not going to be as simple as I hoped. 

1 0
replied on January 5, 2024

Hi Jonathan, since this has been hanging around without comments I was wondering: do you NOT want to use the classic designer?

0 0
replied on January 5, 2024

No, we would much prefer to use the new designer, especially for this form. We've put months of work into designing this form and process. I know what I'm looking for would probably be possible with JavaScript in the classic form, but I was entering this as a feature request for the new designer.

1 0
replied on January 5, 2024

Ahh ok. I misread that...But I took a crack at it anyway. Would this work? This is the modern designer using the LFForm object. 

 

0 0
replied on January 8, 2024

Are those options hardmapped in the JavaScript? I was looking to use a Lookup Rule to fill the check/radio options from SQL. Unless I can do a lookup into a dropdown or single line, then use LFForm to getFieldValues and then setFieldValues? It's something else to try, at least.

0 0
replied on January 8, 2024

Yes this is using a lookup rule. And just to reiterate, this is the modern designer. 

There are 4 fields on this test form, 
-Drop Down for Department (ID 1)
-Single Line (to duplicate the department // hidden // acts as criteria to load data against (ID 2)
-Radio Button for Divisions (ID 3)
-Checkbox for Divisions (ID 4)
*I kept both the Radio and checkbox in the test form so you could see it works for both - you will likely settle on one of the other. 

I created lookup rule(s) one for the radio and one for the checkbox. They are sourcing from the identical query and table. (You will only need one or the other). 

The lookup rule looks to the hidden field for criteria to SELECT from the table. 

And here is the LFForm code. I just needed to subscribe to the onFieldChange for  fieldId 1. And each time that field changes, it sets the value of the hidden field to the selected Department. When the Department updates in the hidden field, the lookup query fires. 

LFForm.onFieldChange(() => LFForm.setFieldValues({fieldId: 2}, LFForm.getFieldValues({fieldId:1})), 
                   {fieldId: 1});

 

0 0
replied on January 8, 2024

It doesn't make sense. I can't select any check or radio field in the Fill portion of the query. However, I have no problem using a dropdown as a condition.

I even recreated the SQL View I'm using into a Stored Procedure, since it looks like that's what you're using, and get the same outcome. Department below is the dropdown.

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

Sign in to reply to this post.