How to dynamically show and hide the fields in the Request page of Business Central?

Introduction:

Based on certain values dynamically show and hide the fields in the request page of the report. Ideally, we cannot directly use visible property to fields. we can do this by enabling the visibility of fields using groups.

Steps to achieve the goal:

  1. Create a groups and add the fields which you want to show and hide based on selected data.

For example, I have an option filed called Filter By- State, Customer, and Both.

If I choose Customer then the Customer field should be visible and if I choose State then the State field should be displayed if I choose both then the Customer and State field should be visible.

  1. Create a 2 boolean variable which is of InDataset
  1. Create Customer and State field and assign it to groups in report.
  1. Then the field value which is been used to show or hide other fields write the below code OnValidate trigger

So the above code will do the following if my Filter By field is State then the State field will be visible and if it is Customer then only the Customer field will be visible. If both are selected then both Customer and State fields will be visible.

Note: If you want to show or hide the field based on only one value then you don’t need to use the InDataset attribute on the Boolean variable

Conclusion:

Thus we saw how we can dynamically show and hide the fields based on selected values on the request page in Business Central.

Thank you very much for reading my work. Hope you enjoyed the article!


Share Story :