Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to create a tool that allows a user to update a table row without starting an edit session. I have a script tool set up with a record set parameter and I use this set up to add new rows to the table. It works well. What I would like to do now is load the record set parameter with the rows that will be edited. I am trying to do this in the updateParameters() method. However, when I load the parameter nothing happens in the dialog. I can see the record set in table of contents and its getting loaded but its as though the parameter is not updating.

Anyone had any success with something like this?

I have tried several ways to load the record set. My latest attempt is with a cursor. Here is the tool validation code for this latest attempt. I have three parameters, an input table view, an input record set, and an input string that I use for printing debug statements. The input record set has the schema imported from the table view I am trying to load.

import arcpy

def rows_as_dicts(cursor):
    colnames = cursor.fields
    for row in cursor:
        yield dict(zip(colnames, row))

def newRowFromDict(cursorFieldsTuple, inDict):
    newRow = []
    for field in cursorFieldsTuple:

    for item in inDict:
        newRowIndex = cursorFieldsTuple.index(item)
        newRow[newRowIndex] = inDict[item]
    return newRow

class ToolValidator(object):
  """Class for validating a tool's parameter values and controlling
  the behavior of the tool's dialog."""

  def __init__(self):
    """Setup arcpy and the list of tool parameters."""
    self.params = arcpy.GetParameterInfo()

  def initializeParameters(self):
    """Refine the properties of a tool's parameters.  This method is
    called when the tool is opened."""

  def updateParameters(self):
    """Modify the values and properties of parameters before internal
    validation is performed.  This method is called whenever a parmater
    has been changed."""
    pymsg,msgs = " No "," Problems"
    if self.params[0].altered and not self.params[0].hasBeenValidated:
        if not self.params[0].value == None:

            thetable = self.params[0].value
            recordSet = self.params[1].value
                inCur = arcpy.da.InsertCursor(recordSet, "*")
                inDict = dict.fromkeys(inCur.fields)
                inFields = inCur.fields

                searhcur = arcpy.da.SearchCursor(thetable, "*")
                searchDict = rows_as_dicts(searhcur)

                for row in searchDict:
                    for item in row:
                        if item in inFields:
                            inDict[item] = row[item]
                    newRow = newRowFromDict(inCur.fields, inDict)

                del inCur

                import sys
                import os
                import traceback    
                tb = sys.exc_info()[2]
                tbinfo = traceback.format_tb(tb)[0]
                pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
                msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"

            self.params[2].value = "Validation" + pymsg + msgs + " end"

  def updateMessages(self):
    """Modify the messages created by internal validation for each tool
    parameter.  This method is called after internal validation."""
share|improve this question
After lots of back and forth with ESRI support it sounds like this is not possible as of 10.1 SP1. –  TurboGus Dec 28 '12 at 21:26
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.