Script Examples: Search for Fields

Find fields of a specific type

Fields can be searched by type. The type names are all lowercase, so searching with the equality operator (==) should be followed with the lowercase value of the field name (it is case sensitive).

The type name can also be searched with the equals ignore case operator(~=) which can be followed with the type name in any case format. See the following examples.

Case Sensitive

var barcode = FORMAT.findFields("type=='barcode'");

LOG.info("***1 Barcode is "+barcode[0].name);

Case Insensitive

var barcode = FORMAT.findFields("type~='Barcode'");

LOG.info("***2 Barcode is "+barcode[0].name);

barcode = FORMAT.findFields("type~='BARCODE'");

LOG.info("***3 Barcode is "+barcode[0].name);

barcode = FORMAT.findFields("type~='BaRcOdE'");

LOG.info("***4 Barcode is "+barcode[0].name);

Search for fields of a specific type and name and make them invisible

var fields = FORMAT.findFields("(type=='label' || name=='text3') && visible=='true'”);

for(i=0;i<fields.length;i++){

  var f = fields[i];

  f.visible=false;

}

Find all fields that are visible

var flist = FORMAT.findFields("visible=='true'”);

LOG.info("Field count is "+flist.length);

for(var i=0; i < flist.length;i++){

  LOG.info("Field name "+flist[i].name);

}

Find all fields

var flist = FORMAT.findFields("");

LOG.info("Field count is "+flist.length);

for(var i=0; i < flist.length;i++){

  LOG.info("Field name "+flist[i].name);

}

Find all fields where the data has been set by calling setData()

var setFields = FORMAT.findFields("dataSet == 'true'");

var notSetFields = FORMAT.findFields("dataSet != 'true'");