Expand my Community achievements bar.

Setting Subform Fields to Required & the Print Button

Avatar

Former Community Member

For an RBList with dedicated subforms per each selection... how can the dedicated subform fields be set to required and still allow the user to print without completing all other required subform fields. For example, if user chooses A from the RBList, then all SubformA fields must be completed before printing. At the same time, those subform fields hidden in SubformB are not necessary to complete because the user selected A. SubformB required fields are only required if user chooses B from the RBList.

What do I need to do to instruct the Print Button to react accordingly?

I've attached the form for reference. RBList A (Contoured Perforation) and B (Standard Perforation) each have dedicated subform fields that should be set to required.

7 Replies

Avatar

Former Community Member

You could set the fields as non mandatory when you set the presence of the subform.

paul

Avatar

Former Community Member

Hi again, Paul -

Do I need to recreate the subform to do so?

Or, could I just add an if...else script to the Print Button code to isolate required fields based on RB selection?

The subform fields are currently set as optional, but my clients want them to be required fields on the form.

I have a prompt code on the print button to alert users if they have not completed all mandatory fields. If I set all of the subformA and subformB fields to required so they highlight for users when the Highlight Fields button is activated in Reader, then the prompt on the Print Button fails when users choose either A or B, then complete only subsequent subformA fields or subformB fields.

Brian

Avatar

Former Community Member

Its not the subforms that are required it is the fields in the subforms. You already have an if statement that tells you what option the user chose...simply add the code the change the field to mandatory when you make it visible and clear it when you make the field hodden.

Paul

Avatar

Former Community Member

That's what I thought I'd need to do. Admittedly, I'm not the best js code writer. I'll give it a shot, though, and see if I can make it work. I need to apply the same restrictions to multiple forms, so it will be a big plus to get this one under my belt. Thanks Paul.

Avatar

Former Community Member

Paul,

Looks like I need some assistance with this code. Does it belong on the Print Button code that is already written? If so, can you provide a sample of what it should look like? I'm not having any luck. Again, my code writing is limited. I appreciate your assistance.

Brian

Avatar

Former Community Member

Repost your form and I will have a look. I want to make sure we are working from the same source.

Paul

Avatar

Former Community Member

Hey Paul,

I was away from my office when you replied. I've saved a copy of the same form you helped me with last week. On this version, I've set Subform A, TrimColorDropDown and TrmPaintDetailDropDown to required. Likewise, I've set Subform B, WoodToneDropDown and WdTnPaintDetailDropDown to required.

You'll notice the code that was written for the Print Button to prevent users from saving/printing the form until all mandatory fields have been completed.

If the user choose RBList A, he/she should need to fill out the two fields I've set to required. Vice versa, if he/she chooses RBList B, those two required fields should be mandatory.

I'm unsure how to write a code or where to put it to make the hidden required fields turn off if the user's selection makes them irrelevant during print/save function.

I've read other topics on the forum, but haven't exactly found a situation like this that would solve my problem. Any advice you have or code suggestions are truly appreciated.

Brian