Skip to main content
eastlakesu3a
Participant
June 17, 2017
Answered

Selecting & Ordering form fields in a QR object

  • June 17, 2017
  • 1 reply
  • 1063 views

I am having problems with Acrobat XI in setting the sequence of field in a QR code on a form. The default seems to be alpha sequence even if I modify the custom script but I need to output to an Excel sheet in a defined order. Can anyone help me re-order the field in the barcode please?

This topic has been closed for replies.
Correct answer eastlakesu3a

There is no sort command, but the way it works is it scans the entire fields array of the file, matching each field's name against the array of fields provided to it, and if a match is found it includes that field's value in the output. So in effect the order used is the internal order of the fields in the file, which is usually the order they were created.

If you want to change that you would need to re-write the code above so it iterates over the aFields array directly, instead.


Ok try67 I underfstand that but now I have to dig around and find out how to do this in java.  It will keep me out of mischief anyway.  Thanks for the help.   Mel

1 reply

Inspiring
June 17, 2017

How did you modify the calculation script? That is what you'll need to do.

eastlakesu3a
Participant
June 17, 2017

Tks for the reply Geoge. This is how I modified the script.  Sorry but I am not an expert by any means and java is a foreign language to me although it has similarities to some others.

The sequence I want the fields in are StudentID, FirstName, LastName as in the modified script below. However I suspect that there is a sort statement somewhere that is creating the barcode in alpha sequence and I have no idea which statement it is. This script is the one that appears when I change the value to custom script onproperties.

/* Customize: */

function bMemberOf(strName, aStrNames)

{

    for (var nMembIdx in aStrNames)

    {

        if (strName == aStrNames[nMembIdx])

            return true;

    }

    return false;

}

function strTabDelimited(oParam)

{

    var bNeedTab = false;

    var strNames = "";

    var strValues = "";

    for (var i = 0; i < oParam.oDoc.numFields; ++i)

    {

        var strFieldName = oParam.oDoc.getNthFieldName(i);

        if ((null == oParam.aFields || bMemberOf(strFieldName, oParam.aFields))

            && (null == oParam.strXclField || strFieldName != oParam.strXclField)

            && (oParam.oDoc.getField(strFieldName).type != "button"))

        {

            if (bNeedTab)

            {

                if (oParam.bFieldNames)

                    strNames += "\t";

                strValues += "\t";

            }

            if (oParam.bFieldNames)

                strNames += strFieldName;

            strValues += oParam.oDoc.getField(strFieldName).value;

            bNeedTab = true;

        }

    }

    if (oParam.bFieldNames)

        return strNames + "\n" + strValues;

    else

        return strValues;

}

try

{

    if ( app.viewerVersion >= ADBE.PMD_Need_Version )

        event.value = strTabDelimited({oDoc: this, aFields: ["StudentID", "FirstName", "LastName"], bFieldNames: false});

    else event.value = " ";

}

catch (e)

{

    event.value = " ";

try67
Community Expert
Community Expert
June 18, 2017

There is no sort command, but the way it works is it scans the entire fields array of the file, matching each field's name against the array of fields provided to it, and if a match is found it includes that field's value in the output. So in effect the order used is the internal order of the fields in the file, which is usually the order they were created.

If you want to change that you would need to re-write the code above so it iterates over the aFields array directly, instead.