Tip>Designer

Iterating over the fields in a Dialog

 

Article #:

0042

Contributor:

Daniel Todes

GF version:

All

Applies to:

Dialogs

Last updated:

June 4, 2002

Description

Iterate over the fields in a Dialog without knowing the names of the fields.

Explanation

You can iterate over the fields in a Dialog and access specific information about them, such as the name of the field, the value contained within the field and whether the field has been answered or not.

 

The following script illustrates how to do this:

 

NOTE

When reviewing the script below, bear in mind that:

  • The field index count starts at zero (0).

  • There will be some "system" fields, e.g.,"_version" and "_mapping", but these can easily be stripped out as their first character will always be an underscore ( _ ).

 

%[i=0]

%[RepeatBlockWhile(i<thisDialog.DynamicPropertyCount)]

%[DeleteBlockIf(Left(thisDialog.DynamicPropertyName(i),1)="_")|This removes system fields]

%[MsgBox("Field Name:", thisDialog.DynamicPropertyName(i))]

%[MsgBox("Field Value:", thisDialog.DynamicPropertyValue(i))]

%[MsgBox("Answered:", thisDialog.Form.Fields.GetV(thisDialog.DynamicPropertyName(i)).Answered)]

%[EndBlock()]

%[i=i+1]

%[EndBlock()]