getRow value in data driven pages help

3377
3
Jump to solution
10-31-2011 05:54 PM
HaydenLewis
New Contributor II
I have an issue trying to get the value of the "WP_NO" field from the index layer.

[HTML]import arcpy, time
mxd = arcpy.mapping.MapDocument(r"F:\TEMP\STRATEGIC_CONN_MAPBOOK_2011_TEST1.mxd")
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
mxd.dataDrivenPages.currentPageID = pageNum
pageName = mxd.dataDrivenPages.pageRow.getValue("WP_NO")
print pageName[/HTML]

I have also unsuccessfully tried pageName = mxd.dataDrivenPages.pageRow.index

The error I always get is this:
File "C:\Python26\ArcGIS10.0\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 312, in RunScript
exec codeObject in __main__.__dict__
File "F:\SCRIPTS\CHARTS\DATADRIVENPAGES_test.py", line 5, in <module>
pageName = mxd.dataDrivenPages.pageRow.getValue("WP_NO")
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects\arcobjects.py", line 945, in getValue
return convertArcObjectToPythonObject(self._arc_object.GetValue(*gp_fixargs(args)))
RuntimeError: ERROR 999999: Error executing function.
0 Kudos
1 Solution

Accepted Solutions
JeffBarrette
Esri Regular Contributor
I just ran into this exact issue today.  My table name and alias name were different.  I had a table join in place so when I tried to search using the alias name, it failed.  When I used the full table name, it worked.

For example,
fieldValue = row.getValue("FieldName") - this failed with the error you note.
fieldValue = row.getValue("TableName.FieldName") - this worked

Jeff

View solution in original post

3 Replies
JeffBarrette
Esri Regular Contributor
I wonder if it is data specific.  What type of value are you trying to get?  Is the value null, a blank string, etc?  I notice in one case you use "WP_NO" and in your second example you use pageRow.index.  Are you on 10.0 SP3?


I just tried:
fieldValue = mxd.dataDrivenPages.pageRow.State_Name
fieldValue = mxd.dataDrivenPages.pageRow.getValue("State_Name")

and they both worked.

If you could send me a map package of your data, I'd be happy to look into it further.  Send to jbarrette@esri.com.


Thanks,
Jeff
JeffBarrette
Esri Regular Contributor
I just ran into this exact issue today.  My table name and alias name were different.  I had a table join in place so when I tried to search using the alias name, it failed.  When I used the full table name, it worked.

For example,
fieldValue = row.getValue("FieldName") - this failed with the error you note.
fieldValue = row.getValue("TableName.FieldName") - this worked

Jeff
HaydenLewis
New Contributor II
Thankyou very much!!!! You were spot on!!!:D. I had forgotten all about the join in the table! Your help is much appreciated Jeff!