Quantcast
Viewing all articles
Browse latest Browse all 1237

Javascript for reading the result of xfa.resolveNodes by index

Hi,

 

I've created an Adobe Interactive form, which allows a user to enter a material number, with the material number being validated against a list of materials embedded into the form, and the Old Material Number and Description being automatically populated if a match is found.  The form is created with around 3,000 materials embedded, which gives an acceptable file size of around 600Kb.  This is a proof-of-concept form at the moment to see if it's worth using this technique.

 

The following Javascript is contained within the Exit Event of the Material field:

 

(IT_MAT is the internal table of materials, mapped to the context)

 

// Read all Material data

  var Mats = xfa.resolveNodes("$record.IT_MAT.DATA[*]");
  var numRows = xfa.resolveNodes("$record.IT_MAT.DATA[*]").length;

 

// Loop through until a match is found
  var found = false;
  for (var i = 0; i < numRows; i++) {

    if (this.rawValue == Mats.item(i).MATNR.value) {

      BISMT.rawValue = Mats.item(i).BISMT.value;
      MAKTX.rawValue = Mats.item(i).MAKTX.value;

      found = TRUE;
      break;    
    }
  }

 

// Invalid Material
  if (!found) xfa.host.messageBox("Invalid Material " + this.rawValue);

 

This works perfectly, but the only problem is the inefficiency of having to loop through 3,000 records to find out that the entered material is invalid, which takes a few seconds.

 

My question is how to search the "Mats" object by key, in the same way as you would in ABAP with a READ TABLE itab WITH KEY matnr = matnr.  I thought that the indexOf method would work with the Mats object, but it doesn't.

 

There is some XFA documentation at the following location, but it doesn't help either.

 

http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/acro7jsguide.pdf

 

Thanks,

Pete


Viewing all articles
Browse latest Browse all 1237

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>