BPC-Components

Home > Products > BPC PowerForms > Knowledge Base > How To Articles > Show or Hide a control based on form conditions

Show or Hide a control based on form conditions

In order to hide/show controls on the form, we can either use the "Visibility Formula" which is inside the control properties window in the designer, or write some script to perform the same action.

Examples :

Condition based on the value of another control :

Code

form.GetControl("c_Status") != "Rejected"

Condition based on logged in user :

Code

form.UserID() == "1" || form.UserInGroup("Administrators") || form.UserInGroup("3")

Visibility from script

Inside the Value-Change event of the "c_Customer" control :

Code

var target = form.GetControl("c_Priority");

var source = form.GetControl("c_Customer");

if (source.GetValue() == "1;#BPC") target.SetVisible(false);

else target.SetVisible(true);