Best of Support

Conditional appearance of fields in a Dialog

Issue

I am working on a Dialog where a variable should be set to INVISIBLE unless two preconditions are met. A single precondition is easy. But I am having trouble on scripting two preconditions. 

Solution:

Question:

Do I put it as an event on the Form? That would seem to be the solution, but the OnLoad doesn't work because the preconditions are variables on the form that have not been answered OnLoad. 

Answer:

You would use event scripting on the Dialog, but it should be scripting on the OnExit or OnChange event of the fields that would determine whether the field should be visible or invisible. For example let's say that you have two fields called IsRed and IsYellow that are True/False. You want a third field, IsGreen to be visible only if IsRed and IsYellow are True. To do so, put the following script in the OnChange Event of BOTH the IsRed and IsYellow fields:

%[IfTrue(ThisDialog.Form.Fields.IsRed And ThisDialog.Form.Fields.IsYellow, ThisDialog.Form.Fields.IsGreen.Visible = True, ThisDialog.Form.Fields.IsGreen.Visible = False)]

Or, even more elegantly:

%[ThisDialog.Form.Fields.IsGreen.Visible = IfTrue(ThisDialog.Form.Fields.IsRed And ThisDialog.Form.Fields.IsYellow, True, False)]

 

Question:

Do I put an event on the variable I want INVISIBLE or VISIBLE. If so, how do I script it?

Answer:

No, see above

 

Question:

Do I put it on each of the preconditions? If so, which precondition and does it matter? 

Answer:

Yes, as shown above. 

 

Question:

Do I need a parallel condition to make the variable INVISIBLE when the preconditions

are no longer valid? 

Answer:

No, see above. 

 

Doug Simpson