Select to view content in your preferred language

Enhanced Search Widget - Loading userlist from attributtable?

2676
6
09-18-2012 05:40 AM
YvonneDeus
Emerging Contributor
Hi,
I have a very long userlist (>50 entries), but it´s necessary.
Is ist possible to load the attributes from the attribute table instead of writing the list?

my code:
[HTML]<expression alias="Flurstück" textsearchlabel="Flurstückssuche" isvaluerequired="false">
<values>
<value prompt="Gemarkung" userlist="Günne,Meschede-Stadt,etc" isvaluerequired="false">upper(locationhierarchy_text) = upper('[value]')</value>
<value prompt="Flur z.B.: 6" isvaluerequired="false">upper(subdivisionnumber) = upper('[value]')</value>
<value prompt="Flurstück z.B.: 273" isvaluerequired="false">upper(parceloflandnumber) = upper('[value]')</value>
</values>
</expression>
[/HTML]
I tested something like: userlist="(locationhierarchy_text)"
Tags (2)
0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Emeritus
Yvonne,

   No that is not possible as that would be a very close duplication of the domain ability that the eSearch already has. So the two options available are to manually type a userlist or to use a coded value domain for your geodatabase of the list.
0 Kudos
AnthonyGiles
Honored Contributor
Hi Yvonne and Robert,

I hope you don't mind me interjecting but creating lengthy userlists is something that I have had to do on many occasions, the workflow I use to create the list is as follows:

1. Export the attribute table to a .dbf file.
2. Open the .dbf in excel, highlight the column I want to create the userlist for and then use the remove duplicates tool under the data ribbon to give me a list of unique values. Optionally sort A-z so the the list is presented alphabetically.
3. Copy the column and open up word. Paste the column using paste special, unformatted text (otherwise it will paste in as a table).
4. Do a find and replace using ^p (newline in word) with , (comma). You should then have a list of comma separated values.

Hope this helps

Regards

Anthony
0 Kudos
YvonneDeus
Emerging Contributor
OK! Thanks you both.
So I don´t needed to waste time for searching a html code ;-). I´ll try your copy & paste variance and then I have to rember if my attribute table will be changed.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Yvonne,  

    Be sure to mark Anthony's post as the answer.

Click the Mark as answer check on this post and to click the top arrow (promote).
Follow the steps as shown in the below graphic on his post:

0 Kudos
RhettZufelt
MVP Notable Contributor
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_
0 Kudos
RhettZufelt
MVP Notable Contributor
Won't let me edit the post, so here is "fix" to code:

      repStr =  35*" " + "<!--" + searchText + "-->" + '<value userlist="' + NewString + """all">summary_""" + fieldName + " = '[value]\'</value>""" + "\n"


otherwise, it doesn't know where/what to replace after first run.

R_
0 Kudos