Hi,
so I guess you're trying to get the n-th instance of a master page used as background of a specific form page? In that case you'll need a combination of several scripting methods to find out.
Given you have a field somewhere in the form, to display the current index the script looks this way:
this.rawValue = xfa.layout.pageContent( xfa.layout.absPage(this).toString(), "pageArea", true).item(0).index + 1;
How it works:
Determine the 0-based-page number of the field with xfa.layout.absPage(this) and convert it to a string with toString(). Then get a node list of page areas used for that page with xfa.layout.pageContent( …, "pageArea", true). Now select the first item of that node list by item(0) and return it's 0-based index number and add 1.
Simple, isn't it?! 😉