2 Replies Latest reply on Jan 3, 2011 2:14 PM by Jo_2005

    How to check if a form field exists in an if statement

    Jo_2005 Level 1

      Hello,

       

      I have multiple documents which are made up of a number of different digital signature fields.

       

      The drawings could have digital signature fields from Rev 0 up to Rev 6.

       

      The script will move the existing digital signature fields to the right.

       

      I need to include an if statement to see if a particular field exists on the document and if so move the field.

       

      If the field does not exist then do not move, this is the part of the script that I am having trouble with.

       

      Error:  b has no properties

       

      Can anyone please help in modifying the part of the script which is if (b!=null) // check if the field exists - this part of the script is not working

       

      I would like to keep the one script and not split it upinto multiple scripts, hence the if statement to check if a field exists.

       

      The script is as follows:

       

      // Move Fields to the Right

      var b = this.getField("Chk R0");
      if (b!=null) // Check if the field exists

      var aRect = b.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      b.rect = aRect; // Update the original form field

      var c = this.getField("Des App R0");
      if (c!=null);
      var aRect = c.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      c.rect = aRect; // Update the original form field

      var d = this.getField("Proj App R0");
      if (d!=null);
      var aRect = d.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      d.rect = aRect; // Update the original form field


      var e = this.getField("Chk R1");
      if (e!=null);
      var aRect = e.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      e.rect = aRect; // Update the original form field

      var f = this.getField("Design App R1");
      if (f!=null);
      var aRect = f.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      f.rect = aRect; // Update the original form field

      var g = this.getField("Proj App R1");
      if (g!=null);
      var aRect = g.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      g.rect = aRect; // Update the original form field


      var h = this.getField("Chk R2");
      if (h!=null);
      var aRect = h.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      h.rect = aRect; // Update the original form field

      var i = this.getField("Design App R2");
      if (i!=null);
      var aRect = i.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      i.rect = aRect; // Update the original form field

      var j = this.getField("Proj App R2");
      if (j!=null);
      var aRect = j.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      j.rect = aRect; // Update the original form field

      var k = this.getField("Chk R3");
      if (k!=null);
      var aRect = k.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      k.rect = aRect; // Update the original form field

      var l = this.getField("Design App R3");
      if (l!=null);
      var aRect = l.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      l.rect = aRect; // Update the original form field

      var m = this.getField("Proj App R3");
      if (m!=null);
      var aRect = m.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      m.rect = aRect; // Update the original form field


      var n = this.getField("Chk R4");
      if (n!=null);
      var aRect = n.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      n.rect = aRect; // Update the original form field

      var o = this.getField("Design App R4");
      if (o!=null);
      var aRect = o.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      o.rect = aRect; // Update the original form field

      var p = this.getField("Proj App R4");
      if (p!=null);
      var aRect = p.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      p.rect = aRect; // Update the original form field
      var q = this.getField("Chk R5");
      if (q!=null);
      var aRect = q.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      q.rect = aRect; // Update the original form field

      var r = this.getField("Design App R5");
      if (r!=null);
      var aRect = r.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      r.rect = aRect; // Update the original form field

      var s = this.getField("Proj App R5");
      if (s!=null);
      var aRect = s.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      s.rect = aRect; // Update the original form field


      var t = this.getField("Chk R6");
      if (t!=null);
      var aRect = t.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      t.rect = aRect; // Update the original form field

      var u = this.getField("Design App R6");
      if (u!=null);
      var aRect = u.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      u.rect = aRect; // Update the original form field

      var v = this.getField("Proj App R6");
      if (v!=null);
      var aRect = v.rect;
      aRect[0] += 39;
      aRect[2] += 39;
      v.rect = aRect; // Update the original form field