on 10-16-2014 10:33 AM
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
Hi Peter,
did you try to solve your problem with find / indexof?
You know, something like
Mats.find(BISMT.rawValue)
or
Mats.indexOf(BISMT.rawValue)
~Florian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.