Best way to hide fields based on a selection

Hello, i have 1 form i would like to use for multiple forms.

The setup..

Title of form : Adjustment Form

Form types/fields available to show from sharepoint

Consumption
• Description
• Item Number
• Lot Number
• Container Number
• MR Number
• Qty

Inventory Adjustment
• Description
• Item Number
• Lot Number
• Container Number
• Current Qty
• Actual Qty

Item Reclass
• Description
• Item Number
• Lot Number
• Container Number
• MR Number
• New Lot Number

I am looking for a good way to make the form show the fields listed based on the Form Type field, the choices are either Consumption, Inventory Adjustment or Item Reclass.

this is from a sharepoint list and i am trying to code this via Java script in plumsail. any advice on how you would tackle this or the easiest way to use one column for all 3 forms but just hide the ones not needed based on the form type selected?

Hi @Christinabobina,

The simplest approach is to hide/show fields depending on formType, as described in this article. However, there's an approach with less copy-pasting:

1. Configure field classes

Set an appropriate class for each field you need to show or hide. For example, "consumption", "inventory-adjustment", and "item-reclass". We'll use these classes to determine when to hide or show fields.
2024-05-29_20-47-57

2. Hide fields based on their class

We'll check formType each time the form is loaded and hide the fields with the wrong classes.

Add the following code to your fd.rendered() function:

if (formType != "Consumption") $('.consumption').hide();
if (formType != "Inventory Adjustment") $('.inventory-adjustment').hide();
if (formType != "Item Reclass") $('.item-reclass').hide();

You might need to adjust the code depending on the formType variable type.
Let me know if this helps.

Thanks you for your help IliaLazarevskii,
If i wanted the field named Description to show for all 3 form types, how would properly code the class section?

Hi @Christinabobina,

You can leave the Class property of that field blank so it won't get hidden.