All,I have had this need myself, normally due to a dynamic "userlist" that could possibly change from day to day as data is added.My "solution" was to make a python script that gets the unique values from my data, makes a replacement string, searches the eSearchWidget.xml for a particular string, and replaces that line with the newly created line.Basically, in the eSearchWidget.xml I add something similar to <!--replace1_start--><value userlist="value1, value2, all">summary_Milestone_Date = '[value]'</value>
. then my script will look for the respective "replace1, replace2" section so it knows what line to "replace".Here is the snippet if anyone is interested, I have configured it as a def so at the bottom, you can make the list of fields/search text and it will run through them all.# Import arcpy module
import arcpy,shutil,fileinput,io
# Local variables:
summary = "\\\\mcflight01\\MCFlightData\\HGIS\\Data\\data_4_temp_services.gdb\\summary" # my dataset I'm searching against
temp_path = "D:\\baks\\dont_use\\temp.gdb\\"
config_file = "\\\\gis01\\C\\inetpub\\wwwroot\\WCH_WIDS_Status\\widgets\\eSearch\\eSearchWidget.xml"
ifile = "D:\\baks\\dont_use\\eSearchWidget_template.xml"
ofile = "D:\\baks\\dont_use\\eSearchWidget.xml"
# Overwrite pre-existing files
arcpy.env.overwriteOutput = True
# copy config file to a working copy
shutil.copy2(config_file, ifile)
def UniqueList():
DataList = []
NewString = ''
temp_freq = temp_path + fieldName + "_freq"
#
# Process: Frequency to get unique list by fieldName
#
arcpy.Frequency_analysis(summary, temp_freq, fieldName, "")
for row in arcpy.SearchCursor(temp_freq, "", "", fieldName):
DataList.append(row.getValue(fieldName))
NewString += str(row.getValue(fieldName)) + ","
#
# Set value for replacement string
#
repStr = 43*" " + '<value userlist="' + NewString + """all">summary_""" + fieldName + " = '[value]\'</value>""" + "\n"
#
# Open file to read values
#
with open(ifile,"r") as infile:
with open(ofile,"w") as outfile: # open file to be able to write to
for i, line in enumerate(infile):
if searchText in line: # Check to see if the searchtext is in this line
line = repStr
outfile.write(line) # If so, replace this line with the string value of repStr.
outfile.close #close outfile
infile.close #close infile
shutil.copy2(ofile, ifile) #copy the outfile to the new infile so it doesn't clobber last changes
#
# List of field names and respective replace text.
# Just add another fieldName/searchText pair and send to UniqueList()
#
# userlist for Milestone_Date
fieldName = "Milestone_Date"
print "processing ",fieldName
searchText = "replace1"
UniqueList()
# userlist for FINAL_ROD_DEC_UNIT
fieldName = "FINAL_ROD_DEC_UNIT"
print "processing ",fieldName
searchText = "replace2"
UniqueList()
# userlist for Note
fieldName = "Note"
print "processing ",fieldName
searchText = "replace3"
UniqueList()
# userlist for Date
fieldName = "Date"
print "processing ",fieldName
searchText = "replace4"
UniqueList()
print "Done"
Of course, this example writes to a copy of the eSearchWidget.xml. just need to modify the path to actually have it make the update.This script then runs every night to incorporate the days changes.Hope this helps someone,R_