Hi Shibi,
The first issue you hit is a bug that has already been fixed.
Let me provide two examples of how to dynamically set the visibility of a field.
1. Within a Coach
If you are within a Coach and have individual fields, then you can set the visibility by rules or script. In my example, I have a simple form with first name, last name, has email, and email address. If "has email" is true, then the email address text field is set to required and enabled, otherwise it is not required and not enabled.
Unchecked state:

Checked state:

To accomplish the above, I have variables declared in the CSHS for each field:

On the email address field, I set the visibility by script and base it on the variable bound to the checkbox. I could have also used the Rule option:

2. Within a View
In your question, it looks like you are using a View, which does not have the option of a rule or script. For this case, you need to use the events of the controls. In my next example, I have all the fields declared on a Customer business object, with the View using this business object as its business data:

In the layout, we can add code to the events of the checkbox control to set the visibility of the sibling email address view:

Where emailAddress1 is the control ID of the email text field. For more details about these scripts and APIs, see: https://www.ibm.com/docs/en/baw/23.x?topic=api-check-box
I hope this helps.
------------------------------
Grant Taylor
------------------------------
Original Message:
Sent: Tue September 05, 2023 02:19 PM
From: Shibi John
Subject: How do I set Visibility = "Required" for a field based on input logic user has selected?
Hi,
I would like to mark a field as required with a red asterisk on the label. I am able to do this by setting "Visibility="required" .
But noticed I am not able to save this change. The save icon is enbaled..
Note: I am able to set the same for other fields successfully.It is only happening for this "Email" field..
2. Also I would like to know if there is another way to set it in any of the events? what is the command?
3. how do I set the Visibility in the events based a user input? for example: if user selects "Yes" on fieldA, then the Visibility of "Email" should be "Required". Else if it is "No" then set Visibility = Same as Parent
------------------------------
Shibi John
------------------------------