<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Issues with sorting using arcpy.na.AddLocations in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/issues-with-sorting-using-arcpy-na-addlocations/m-p/1094183#M62214</link>
    <description>&lt;P&gt;I was trying "work_order_number" originally as this was a field I added to the analysis layer, but then I switched to "Name" as that seems to be a default field for Stops in the Route Analysis.&amp;nbsp; The attributes list the Field Name as "Name" and the alias as "Name".&amp;nbsp; Is it possible that the type of sort is limited to only certain types of properties?&lt;/P&gt;&lt;P&gt;Thanks again for your help on this!&lt;/P&gt;</description>
    <pubDate>Tue, 31 Aug 2021 20:56:36 GMT</pubDate>
    <dc:creator>JeffHaupt</dc:creator>
    <dc:date>2021-08-31T20:56:36Z</dc:date>
    <item>
      <title>Issues with sorting using arcpy.na.AddLocations</title>
      <link>https://community.esri.com/t5/python-questions/issues-with-sorting-using-arcpy-na-addlocations/m-p/1094143#M62210</link>
      <description>&lt;P&gt;Hey everyone!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new both to the community and to ArcGIS.&amp;nbsp; I have been tasked with creating a python script that will complete a route analysis on a regular basis and so far that has been successful.&amp;nbsp; One issue that I am having is that I am trying to sort of the field work_order_number, but I'm not quite sure how to do that.&amp;nbsp; Here is the code that I have used to be able to create the route layer and add the stops with additional fields, but I have tried several ways to sort using the sort_field in AddLocations and was even trying to use arcpy.da.UpdateCursors.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;routeLayer = arcpy.na.MakeRouteAnalysisLayer("https://www.arcgis.com/", f"Best Route {route_type_entry}", "Driving Time", "PRESERVE_FIRST", None, "LOCAL_TIME_AT_LOCATIONS", "ALONG_NETWORK", None, "DIRECTIONS", "LOCAL_TIME_AT_LOCATIONS")
    
    #Adding fields to the route layer that were from the original table
    #layer_object allows us to access the necessary parts of routeLayer to be able to add specific fields
    layer_object = routeLayer.getOutput(0)
    added_fields = [["Service_Address", "TEXT"],["Work_Order", "TEXT"],["Service_Date", "DATE"],["Route_Type", "TEXT"],["Description", "TEXT"],["Item_Size", "TEXT"],     ["Work_Order_Status", "TEXT"]]
    for i in range(len(added_fields)):
        arcpy.na.AddFieldToAnalysisLayer(layer_object, "Stops", added_fields[i][0], added_fields[i][1])
    
    ## This process is importing the XY points into the route layer to be analyzed 
    ## What is being passed in is the Network Analysis Layer, Stops table, the temporary view table, fields we want to include values for
    arcpy.na.AddLocations(routeLayer, "Stops", viewTable, "CurbApproach # 3;Work_Order work_order_number #; Service_Address request_address #; Service_Date scheduled_pickup_date #; Route_Type route_type #; Description description #; Item_Size item_size #; Work_Order_Status work_order_status #;", "5000 Meters", None, None, "MATCH_TO_CLOSEST", "APPEND", "NO_SNAP", "5 Meters", "EXCLUDE", None)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help that I can get on this would be appreciated!&amp;nbsp; Like I said, I'm brand new to the arcpy and ArcGIS world.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 19:24:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issues-with-sorting-using-arcpy-na-addlocations/m-p/1094143#M62210</guid>
      <dc:creator>JeffHaupt</dc:creator>
      <dc:date>2021-08-31T19:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with sorting using arcpy.na.AddLocations</title>
      <link>https://community.esri.com/t5/python-questions/issues-with-sorting-using-arcpy-na-addlocations/m-p/1094150#M62211</link>
      <description>&lt;P&gt;You say sorting by parameter in the tool doesn't work, does it do anything?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.na.AddLocations(routeLayer, "Stops", viewTable, "CurbApproach # 3;Work_Order work_order_number #; Service_Address request_address #; Service_Date scheduled_pickup_date #; Route_Type route_type #; Description description #; Item_Size item_size #; Work_Order_Status work_order_status #;", "5000 Meters", "work_order_number", None, "MATCH_TO_CLOSEST", "APPEND", "NO_SNAP", "5 Meters", "EXCLUDE", None)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 19:40:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issues-with-sorting-using-arcpy-na-addlocations/m-p/1094150#M62211</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-08-31T19:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with sorting using arcpy.na.AddLocations</title>
      <link>https://community.esri.com/t5/python-questions/issues-with-sorting-using-arcpy-na-addlocations/m-p/1094159#M62212</link>
      <description>&lt;P&gt;If I use "Name" to sort, I am told that it doesn't exist as a sort field&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 19:59:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issues-with-sorting-using-arcpy-na-addlocations/m-p/1094159#M62212</guid>
      <dc:creator>JeffHaupt</dc:creator>
      <dc:date>2021-08-31T19:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with sorting using arcpy.na.AddLocations</title>
      <link>https://community.esri.com/t5/python-questions/issues-with-sorting-using-arcpy-na-addlocations/m-p/1094180#M62213</link>
      <description>&lt;P&gt;I thought you said work_order_number? So 'name' is the field you want to sort by?&amp;nbsp;&lt;/P&gt;&lt;P&gt;If it's saying it's not a field, perhaps name is an alias, you can check this in the feature class properties.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 20:47:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issues-with-sorting-using-arcpy-na-addlocations/m-p/1094180#M62213</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-08-31T20:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with sorting using arcpy.na.AddLocations</title>
      <link>https://community.esri.com/t5/python-questions/issues-with-sorting-using-arcpy-na-addlocations/m-p/1094183#M62214</link>
      <description>&lt;P&gt;I was trying "work_order_number" originally as this was a field I added to the analysis layer, but then I switched to "Name" as that seems to be a default field for Stops in the Route Analysis.&amp;nbsp; The attributes list the Field Name as "Name" and the alias as "Name".&amp;nbsp; Is it possible that the type of sort is limited to only certain types of properties?&lt;/P&gt;&lt;P&gt;Thanks again for your help on this!&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 20:56:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issues-with-sorting-using-arcpy-na-addlocations/m-p/1094183#M62214</guid>
      <dc:creator>JeffHaupt</dc:creator>
      <dc:date>2021-08-31T20:56:36Z</dc:date>
    </item>
  </channel>
</rss>

