Access page number via script

I need to create a custom bar code with the number of the current page and other fields from database.
How can I access via script the current page number?

First create barcode of your choosing. Then click the expand button. Paste in this code changing to your fields and needs

var cRecord = record.index.toString;
var BC_Field = record.fields.MailToZip;
{
function add(value, operation) {
if (value === undefined || value === “”)
return;
operation(value);
}
var result = “”;
add(cRecord +“0000” + BC_Field, function (value) { result += value; });
results.html(result);
}

var cRecord = record.index.toString; //is current record

You need to add the barcode in the Output Preset Settings.

In v1.4.1,

go to File > Print presets > Output Creation Settings > click Next and select the Add additional content >click Next

Click on the Barcode and OMR Marks tab > select your barcode and in the Text field, the current page number can be access from Infor Field as seen in the attached screenshot.

Please note that you can enter any valid JavaScript code in the Text Area as long as it is enclosed within ${ } as you will see from the below guide.

To use other fields from the data mapper, you will first need to add these fields to the corresponding metadata levels in File>Print Presets>Job Creation Settings > Include meta data

A step by step guide on how to achieve this is available here:

Thanks guys, I will test all the above code.

Is there any way of customising this so that page 1 is A for example? I am trying to create a custom inserter barcode