Expand my Community achievements bar.

Map a range of fields to PDF417 barcode (instead of the whole set)

Avatar

Former Community Member
Hello all,



does anyone has a script for mapping a certain range of fields to be represented in the barcode?



Remark: We tried to understand the syntax of the default script (on calculate) for the Paper Forms Barcode object. Could somebody elaborate on the use of "depends"?



// The barcode will not automatically update when the filled values are changed.

// The work-around is to add a recursive function that goes through all fields in the given node.

function depends(node)

{

for (var i = 0; i < node.nodes.length; ++i)

{

var child = node.nodes.item(i);

if (child.isContainer)

depends(child);

}

}



depends(xfa.form); // force all fields in the form to be updated in the dataset



this.rawValue = xfa.datasets.saveXML();
2 Replies

Avatar

Former Community Member
One of the great things about a PDF is that it fully supports ECMA JavaScript standards so any combination of fields and data can be put together into the Barcode.



The "default" script that you show here is a simple XML example that updates "this.rawvalue" with the XML data of the form. If you are not familiar with the XFA model (how to control a form by using JavaScript) then the .rawValue property is the actual value of an object, and in this case, the Barcode value itself.



That being said, to map individual fields you can put together a Calculate Script like the following:



this.rawValue = Name.rawValue + "|" +

Address.rawValue + "|" +

City.rawValue + "|" +

State.rawValue + "|" +

ZipCode.rawValue + "|" +

Country.rawValue;



In this case the Barcode is on the same subform level as the other fields so we don't have to provide the fully qualified names.



If you are not sure of the full name of a field, while in the script, hold down the "Ctrl" key and then click on the field you wish to include in the script. This will provide you with the XFA resolve:



xfa.resolveNode("BarcodeSize.BarcodeandField.CustomCodeDataEntry.Country")



...then simply add ".rawValue" to the end to extract the value of the field.

Avatar

Former Community Member
Hi Lee,



thanks a lot for the advice, it worked.



Regards,

Evangelos