AnsweredAssumed Answered Map Series- Field Name from code

Question asked by AaronAE on Aug 28, 2018
Latest reply on Jun 28, 2019 by AaronAE

I'm trying to use the arcpy MapSeries Class to generate PNGs for each sheet, based on Code Example #2 here:


I'd like to get the Index field name from the Map Series Index Layer to make the code flexible rather than having to hard-code in the field name in the pageRow property.


My attempts don't work, although it's easy enough to find the  I can't figure out how to pass a variable into the FIELD_NAME portion of the pageRow property.

using either  pageField =

or  pageField = str(

fails on:  pageName = ms.pageRow.pageField

with: AttributeError: 'pageRow' object has no attribute 'pageField'

Is there any way to insert a variable into the Field Name attribute? layout.MapSeries.pageRow.FIELD_NAME


import arcpy

#get parameters
SaveLocation = arcpy.GetParameterAsText(0)

aprx ="CURRENT")
l = aprx.listLayouts()[0]
if not l.mapSeries is None:
  ms = l.mapSeries
  if ms.enabled:
    for pageNum in range(1, ms.pageCount + 1):
      ms.currentPageNumber = pageNum
      pageField =

      pageName = ms.pageRow.pageField

      l.exportToPNG(SaveLocation + "\\" + pageName + ".png")