Problems with Relates and the Enhanced Search Widget

1259
18
Jump to solution
09-11-2012 06:24 PM
GeorgeHaskett
Occasional Contributor III
Hello,

I am trying to figure out how to get my relates functions to work with the Enhanced Search Widget.

I have created a relationship between a layer and a table within ArcMap in my mxd document and created a shared service, however I cannot seem to figure out how to get the relate to populate in the grid and get the relate popup window to open.

Can someone explain the basics, seeing how I am somehow missing something?

Does the relate need to happen within the geodatabase instead of the mxd document?

Thanks,

George
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
George,

   Yes you can have many relates associated with one layer as shown here (one layer from the eSearchWidget.xml that come in the download):

        <!--<layer>             <definitionexpression></definitionexpression>             <enableexport>true</enableexport>             <name>Road Centerlines</name>             <url>http://gislap183/ArcGIS/rest/services/Highway/MapServer/5</url>             <expressions>                 <expression alias="Road Name and Zip" textsearchlabel="Search by Road Name and Left Zipcode and Right Zip:">                     <values>                         <value prompt="Example: ANDREW" isValueRequired="true">RD_NAME = '[value]'</value>                         <value prompt="Example: 36201" isValueRequired="true" operator="AND">ZIP_L = [value]</value>                         <value prompt="Example: 36201" isValueRequired="true" operator="AND">ZIP_R = [value]</value>                     </values>                 </expression>                 <expression alias="Road Surface" textsearchlabel="Search by Surface Type:">                     <values>                         <value prompt="Example: Asphalt" field="Surf_Type" usedomain="true">Surf_Type = [value]</value>                     </values>                 </expression>                 <expression alias="Open SQL" textsearchlabel="Search by Typing Full SQL:">                     <values>                         <value prompt="Example: RD_NAME = 'ANDREW' AND ZIP_L = 36201">[value]</value>                     </values>                 </expression>             </expressions>             <graphicalsearchlabel>Use one of the graphical search tools to select Roads</graphicalsearchlabel>             <spatialsearchlayer>true</spatialsearchlayer>             <titlefield>Name</titlefield>             <fields all="false">                 <field name="Name" gridfield="true" sort="asc|1|string"/>                 <field name="Classification" gridfield="true" />                 <field name="Length_" numberformat="2|,|." />                 <field name="Width" gridfield="true" />                 <field name="L_F_ADD" gridfield="true" />                 <field name="L_T_ADD" gridfield="true" />                 <field name="R_F_ADD" gridfield="true" />                 <field name="R_T_ADD" gridfield="true" />                 <field name="PREFIX" gridfield="true" />                 <field name="PRETYPE" gridfield="true" />                 <field name="RD_NAME" gridfield="true" />                 <field name="TYPE" gridfield="true" />                 <field name="SUFFIX" gridfield="true" />                 <field name="ZIP_L" gridfield="true" />                 <field name="ZIP_R" gridfield="true" />             </fields>             <links>                 <link alias="View Mon. Ref Sheet" diablelinksifnull="true">                     <![CDATA[http://somesite/gis/map/map_search/mrs_test.cfm?mrspoint={xxx}&lat={ZIP_L}&long={ZIP_R}]]>                     <icon><![CDATA[assets/images/w_link.png]]></icon>                 </link>              </links>             <zoomscale usegeometry="true" zoompercent="1.6" />             <autoopendatagrid>true</autoopendatagrid>             <relates>                 <relate id="0" label="ABIMS Bridge" enableexport="true" icon="assets/images/i_hydro.png">                     <fields all="true" />                 </relate>                 <relate id="1" label="Average Daily Traffic" enableexport="true" icon="assets/images/i_flag.png">                     <fields all="false">                         <field name="Date_" dateformat="MM/DD/YYYY" sort="asc|1|date"/>                         <field name="Road_Name" />                         <field name="Road_ID" />                         <field name="Location" />                         <field name="ADT" sum="true" sumlabel="ADT Total Count: " sort="asc|2|numeric"/>                         <field name="Percent_Tr" />                     </fields>                 </relate>                 <relate id="2" label="Railroad Crossings" enableexport="true" icon="assets/images/i_folder.png">                     <fields all="false">                         <field name="Gate" />                         <field name="Lights" />                         <field name="Active" />                         <field name="At_Grade" />                         <field name="Clearance" />                         <field name="Control_Mark" />                     </fields>                 </relate>                 <relate id="3" label="Signs" enableexport="false" icon="assets/images/i_lego.png">                     <fields all="false">                         <field name="Type" />                         <field name="Road_ID" />                         <field name="Condition" />                         <field name="P_Hyper" />                         <field name="Image_" hyperlinkgridfield="true" hyperlinkgridicon="assets/images/i_lego.png"                             hyperlinkaliastext="Get Sign Image" linkprefix="" linksuffix="" />                         <field name="post" />                     </fields>                 </relate>                 <relate id="4" label="Guardrails" enableexport="true" icon="assets/images/i_clock.png">                     <fields all="false">                         <field name="Type" />                         <field name="ID" />                         <field name="Date_P" dateformat="MM/DD/YYYY" />                         <field name="Date_R" dateformat="MM/DD/YYYY" />                         <field name="Type_end_a" />                         <field name="Type_start_a" />                         <field name="Comments" />                     </fields>                 </relate>             </relates>             <queryattachments>false</queryattachments>             <symbology>                 <simplelinesymbol color="0x00ffff" alpha="0.8" width="2" />             </symbology>         </layer>

View solution in original post

0 Kudos
18 Replies
RobertScheitlin__GISP
MVP Emeritus
George,

    When you published your map service did you go to your REST Service directory and verify that the relate is listed at the bottom of that layer in the service directory?
0 Kudos
GeorgeHaskett
Occasional Contributor III
Rob,

No I'm not seeing that anywhere.

Do you have an example of one I could look at to verify it.

Mine is located at:

http://rd.giscenter.isu.edu/arcgis/rest/services/MCPD_beta/MapServer

Does the relate have to occur at the geodatabase level or can I do it at the layer level within the mxd?

Thanks,

Haskett
0 Kudos
AnthonyGiles
Frequent Contributor
George,

Here is a Rest endpoint from one of The esri sample servers that has related tables:

http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/0

Have you made sure that you have cleared your rest cache after you have made changes to your mxd

Regards

Anthony
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
George,

   Now that your relates are showing for your map service do you need anything else as far as getting the eSearch setup to work with the relates data? Make sure you use 0 for the relate id based on your REST Service directory: MCPD_SURVEYOR (0) -- Related To: MCPD_SURVEYOR (8).
0 Kudos
GeorgeHaskett
Occasional Contributor III
Thanks everyone.


@Athony - Yeah the cache settings where a major headache until I had them install CCleaner, which seems to be saving me a lot of time.  Seeing the link helped me visualize what it should look like.  I ended up removing my relate on the map, re-relating it and republishing it.  Then the relates appeared on the REST file.

@Rob - Thanks, I managed to finally get it to work.  I think part of my problem was the fact I was trying to list the table under the table event in the xml doc.

For future reference, can a layer have more than one related table with this tool?

Thanks,

Haskett
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
George,

   Yes you can have many relates associated with one layer as shown here (one layer from the eSearchWidget.xml that come in the download):

        <!--<layer>             <definitionexpression></definitionexpression>             <enableexport>true</enableexport>             <name>Road Centerlines</name>             <url>http://gislap183/ArcGIS/rest/services/Highway/MapServer/5</url>             <expressions>                 <expression alias="Road Name and Zip" textsearchlabel="Search by Road Name and Left Zipcode and Right Zip:">                     <values>                         <value prompt="Example: ANDREW" isValueRequired="true">RD_NAME = '[value]'</value>                         <value prompt="Example: 36201" isValueRequired="true" operator="AND">ZIP_L = [value]</value>                         <value prompt="Example: 36201" isValueRequired="true" operator="AND">ZIP_R = [value]</value>                     </values>                 </expression>                 <expression alias="Road Surface" textsearchlabel="Search by Surface Type:">                     <values>                         <value prompt="Example: Asphalt" field="Surf_Type" usedomain="true">Surf_Type = [value]</value>                     </values>                 </expression>                 <expression alias="Open SQL" textsearchlabel="Search by Typing Full SQL:">                     <values>                         <value prompt="Example: RD_NAME = 'ANDREW' AND ZIP_L = 36201">[value]</value>                     </values>                 </expression>             </expressions>             <graphicalsearchlabel>Use one of the graphical search tools to select Roads</graphicalsearchlabel>             <spatialsearchlayer>true</spatialsearchlayer>             <titlefield>Name</titlefield>             <fields all="false">                 <field name="Name" gridfield="true" sort="asc|1|string"/>                 <field name="Classification" gridfield="true" />                 <field name="Length_" numberformat="2|,|." />                 <field name="Width" gridfield="true" />                 <field name="L_F_ADD" gridfield="true" />                 <field name="L_T_ADD" gridfield="true" />                 <field name="R_F_ADD" gridfield="true" />                 <field name="R_T_ADD" gridfield="true" />                 <field name="PREFIX" gridfield="true" />                 <field name="PRETYPE" gridfield="true" />                 <field name="RD_NAME" gridfield="true" />                 <field name="TYPE" gridfield="true" />                 <field name="SUFFIX" gridfield="true" />                 <field name="ZIP_L" gridfield="true" />                 <field name="ZIP_R" gridfield="true" />             </fields>             <links>                 <link alias="View Mon. Ref Sheet" diablelinksifnull="true">                     <![CDATA[http://somesite/gis/map/map_search/mrs_test.cfm?mrspoint={xxx}&lat={ZIP_L}&long={ZIP_R}]]>                     <icon><![CDATA[assets/images/w_link.png]]></icon>                 </link>              </links>             <zoomscale usegeometry="true" zoompercent="1.6" />             <autoopendatagrid>true</autoopendatagrid>             <relates>                 <relate id="0" label="ABIMS Bridge" enableexport="true" icon="assets/images/i_hydro.png">                     <fields all="true" />                 </relate>                 <relate id="1" label="Average Daily Traffic" enableexport="true" icon="assets/images/i_flag.png">                     <fields all="false">                         <field name="Date_" dateformat="MM/DD/YYYY" sort="asc|1|date"/>                         <field name="Road_Name" />                         <field name="Road_ID" />                         <field name="Location" />                         <field name="ADT" sum="true" sumlabel="ADT Total Count: " sort="asc|2|numeric"/>                         <field name="Percent_Tr" />                     </fields>                 </relate>                 <relate id="2" label="Railroad Crossings" enableexport="true" icon="assets/images/i_folder.png">                     <fields all="false">                         <field name="Gate" />                         <field name="Lights" />                         <field name="Active" />                         <field name="At_Grade" />                         <field name="Clearance" />                         <field name="Control_Mark" />                     </fields>                 </relate>                 <relate id="3" label="Signs" enableexport="false" icon="assets/images/i_lego.png">                     <fields all="false">                         <field name="Type" />                         <field name="Road_ID" />                         <field name="Condition" />                         <field name="P_Hyper" />                         <field name="Image_" hyperlinkgridfield="true" hyperlinkgridicon="assets/images/i_lego.png"                             hyperlinkaliastext="Get Sign Image" linkprefix="" linksuffix="" />                         <field name="post" />                     </fields>                 </relate>                 <relate id="4" label="Guardrails" enableexport="true" icon="assets/images/i_clock.png">                     <fields all="false">                         <field name="Type" />                         <field name="ID" />                         <field name="Date_P" dateformat="MM/DD/YYYY" />                         <field name="Date_R" dateformat="MM/DD/YYYY" />                         <field name="Type_end_a" />                         <field name="Type_start_a" />                         <field name="Comments" />                     </fields>                 </relate>             </relates>             <queryattachments>false</queryattachments>             <symbology>                 <simplelinesymbol color="0x00ffff" alpha="0.8" width="2" />             </symbology>         </layer>
0 Kudos
AaronMielke
New Contributor III
Robert,
[ATTACH=CONFIG]18059[/ATTACH]
I am having a similar problem.  The relate shows up in the REST Service directory but nothing shows up when I click on the folder icon at the bottom of the search results.  I have a Sites layer related to a Documents table.  The table contains a list of documents associated with each of the sites. I wasn't sure which relate id to use, but I have tried all of them 0 thru 6.  I have attached a few screen shots to try and explain.

George,

    When you published your map service did you go to your REST Service directory and verify that the relate is listed at the bottom of that layer in the service directory?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Aaron,

   The relate id should be 0 in your xml configuration for the relate, always use the first number in parentheses reported by the REST service directory.
0 Kudos
AaronMielke
New Contributor III
Robert,
I tried using ID=0 and it still doesn't work.  I can't for the life of me figure out why it wouldn't be working.  Can you see anything in the attached Search Widger.xml

<layers>
  <layer>
   <definitionexpression></definitionexpression>
   <enableexport>true</enableexport>
   <name>Sites</name>
<url>https://XXXXXXX/ArcGIS/rest/services/Test/Test_Map/MapServer/2</url>
   <expressions>
    <expression alias="Name">
     <values>
      <value userlist="1,2,3,4">upper(Name) = upper('[value]')</value>
     </values>
    </expression>
   
                                <expression alias="Parcel ID Number" textsearchlabel="Search Parcel ID#:">
     <values>
      <value prompt="Example: 2102924430038 or 2102%"> PID_NO like '[value]'</value>
     </values>
    </expression>

    <expression alias="Address" textsearchlabel="Building Number and Street Name:">
     <values>
      <value prompt="Example: 801">BLDG_NUM = '[value]'</value>
      <value prompt="Example: 2ND AVE N">AND upper(STREETNAME) = upper('[value]')</value>
     </values>
    </expression>
   
   </expressions>
   <graphicalsearchlabel>Use one of the graphical search tools to select Site</graphicalsearchlabel>
   <spatialsearchlayer>true</spatialsearchlayer>
   <titlefield>Name</titlefield>
   <fields all="false">
    <field name="Name" alias="Site Name" gridfield="true"/>  
    <field name="BLDG_NUM" alias="Building Number" gridfield="true"/>
    <field name="STREETNAME" alias="Street" gridfield="true"/>
    <field name="City" alias="City" gridfield="true"/>
    <field name="PID_NO" alias="Parcel ID#" gridfield="true"/>
         
   </fields>
  
   <zoomscale usegeometry="true" zoompercent="1.6">10000</zoomscale>
   <autoopendatagrid>false</autoopendatagrid>
   <relates>
   
    <relate id="0" label="Documents" enableexport="true" icon="assets/images/i_folder.png">
     <fields all="true"/>
     
    
    </relate>
   
   </relates>

  </layer>
0 Kudos