I have created an XFA form using Adobe Designer (LiveCycle) which utilizes 25 textfields. I am trying to create a 'Redact' button which, when pressed, will iterate through the 25 fields and search for a name in the string value of each field. If the name is found then it replaces the name with "\*\*\*\*\*\*\*\*" using a global RegExp and if not, moves on to the next field. This is what i've come up with so far, but it isn't working. Can anyone help?

```
var name = nameGlobal.value.toString();
 var regExp = new RegExp(name, "gi");
 var fields = [
  xfa.resolveNode("form1.#subform[3].#subform[4].N_Location.F1.TextField5").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].N_Witnesses.Notes_2.TextField5").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].F2.TextField5").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Notes_4.TextField7").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Notes_5.TextField7").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Notes_6.TextField9").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Notes_7.N_7_2.TextField10").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Notes_7.N_7_4.TextField11").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Notes_7.N_7_6.TextField12").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Notes_7.N_7_8.TextField13").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Notes_7.F4.TextField5").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Notes_8.ClinicalNOtes.F5.TextField5").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Notes_8.ClinicalNOtes.F6.TextField5").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Notes_8.ClinicalNOtes.F20.TextField5").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Notes_8.ClinicalNOtes.PupilSize.F7.TextField5").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Notes_8.ClinicalNOtes.F8.TextField5").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Notes_8.ClinicalNOtes.F9.TextField5").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Notes_8.ClinicalNOtes.F10.TextField5").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Notes_8.ClinicalNOtes.F11.TextField5").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Notes_8.ClinicalNOtes.#subform[20].TextField5").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Notes_9.TextField5").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Notes_10.TextField5").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].F13.TextField5").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].F14.TextField5").rawValue.toString(),
  xfa.resolveNode("form1.#subform[3].#subform[4].Msic_Notes.TextField5").rawValue.toString()
];

 for (i = 0; i < fields.length; i++) {
    if (fields[i] !== null) {
    fields[i] = fields[i].replace(name, "********");
     }
    }

```