Skip to main content

First Record of FeatureSet

Comments

10 comments

  • Nico Burgerhart

    Use myFeatureSet.Features.First().Attributes("StructureID").ToString() to get the value.

    You should add a reference to the System.Linq namespace in your workflow to be able to use the First() method.

    The sample above comes comes from the Workflow Designer Help > Key concepts > Queries.

     

    0
  • Permanently deleted user

    Thx for Nico...but what does this mean?

    "System.Linq namespace in your workflow to be able to use the First() method.??

    0
  • Nico Burgerhart

    See the topic Import a Namespace in the Help and see e.g. the code sample here http://msdn.microsoft.com/en-us/library/bb291976.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2

    0
  • Permanently deleted user

    Hi Kenneth

    effectively without adding a bundle of code ie a 'namespace' to your workflow then the process that runs the workflow will not know about a First() method.

    So you need to go to the Imports tab in your workflow designer, type into the search System.Linq and select it from the dropdown list.

    Hope that helps

    Ralph

    PS and check out Nico's answer....

     

    0
  • Permanently deleted user

    I have a similar need. Rather than just capturing the attribute of the first feature, how would I be able to create a string of the same attribute of all the selected features?

    0
  • Ryan Cooney

    Hi Justin,

    If you want to get all of the values for a particular attribute you can use the GetAttributeValues<T> activity. You specify the FeatureSet, the attribute you are looking for and the type of the data in that attribute and it will return a list of just the values.

    --Ryan

     

    0
  • Permanently deleted user

    I felt like it should be something easy like that, just couldn't see it. Thanks for the help Ryan.

    0
  • Ryan Cooney

    One more thing to add. If your goal is to create a string of the attribute values (perhaps comma separated) you can take the list of values from the GetAttributeValues<T> activity and join them like this in an Assign activity:

    string.Join(",", myListOfValues)

    --Ryan

    0
  • Permanently deleted user

    Hi All,

    I have a similar problem, i'm running a query on a layer but I only need the first address returned. 

    However I don't want to turn it into a string as i'm going to add it to a datatable then add that to a dataset.

    This is the workflow section i'm looking at below, any help would be really appreciated.

    Thank You - Laura

     

    <Activity mc:Ignorable="sap" x:Class="{x:Null}" sap:VirtualizedContainerService.HintSize="262,240" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:eac="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client" xmlns:eacg="clr-namespace:ESRI.ArcGIS.Client.Geometry;assembly=ESRI.ArcGIS.Client" xmlns:eact="clr-namespace:ESRI.ArcGIS.Client.Tasks;assembly=ESRI.ArcGIS.Client" xmlns:esri="http://schemas.esri.com/arcgis/client/2009" xmlns:gce="clr-namespace:Geocortex.Core.Extensions;assembly=Geocortex.Core" xmlns:gfc="clr-namespace:Geocortex.Forms.Client;assembly=Geocortex.EssentialsWpfApi" xmlns:gfci="clr-namespace:Geocortex.Forms.Client.Items;assembly=Geocortex.EssentialsWpfApi" xmlns:gr="clr-namespace:Geocortex.Reporting;assembly=Geocortex.Reporting" xmlns:gwa="clr-namespace:Geocortex.Workflow.Activities;assembly=Geocortex.Workflow" xmlns:gwa1="clr-namespace:Geocortex.Workflow.Activities;assembly=Geocortex.Workflow.Activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:s="clr-namespace:System;assembly=System.Core" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=mscorlib" xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

     

      <Sequence sap:VirtualizedContainerService.HintSize="222,200" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces">

     

        <sap:WorkflowViewStateService.ViewState>

     

          <scg:Dictionary x:TypeArguments="x:String, x:Object">

     

            <x:Boolean x:Key="IsExpanded">True</x:Boolean>

     

          </scg:Dictionary>

     

        </sap:WorkflowViewStateService.ViewState>

     

        <Sequence DisplayName="Get Addy" sap:VirtualizedContainerService.HintSize="352,737">

     

          <Sequence.Variables>

     

            <Variable x:TypeArguments="x:String" Default="http://testmapit.fortworthtexas.gov/AGS/rest/services/JenninL/PublicSafetyBaseMap/MapServer/0" Name="addyURL" />

     

            <Variable x:TypeArguments="x:String" Default="AddyClick" Name="sTableName" />

     

            <Variable x:TypeArguments="esri:FeatureSet" Name="fsAddy" />

     

            <Variable x:TypeArguments="sd:DataTable" Name="dtAddy" />

     

          </Sequence.Variables>

     

          <sap:WorkflowViewStateService.ViewState>

     

            <scg:Dictionary x:TypeArguments="x:String, x:Object">

     

              <x:Boolean x:Key="IsExpanded">False</x:Boolean>

     

            </scg:Dictionary>

     

          </sap:WorkflowViewStateService.ViewState>

     

          <gwa1:QueryTask DisplayName="Query Addy" Geometry="[ptUserClick]" sap:VirtualizedContainerService.HintSize="330,227" OutFields="ADDR_NO,STREET_NAME,STREET_TYPE" QueryServiceUrl="[addyURL]" Results="[fsAddy]" ReturnGeometry="False" SpatialRelationship="esriSpatialRelIntersects" />

     

          <gwa1:FeatureSetToDataTable DataTable="[dtAddy]" DisplayName="Addy FeatureSet To DataTable" FeatureSet="[fsAddy]" sap:VirtualizedContainerService.HintSize="330,82" />

     

          <Assign DisplayName="Assign Report Table Name" sap:VirtualizedContainerService.HintSize="330,57">

     

            <Assign.To>

     

              <OutArgument x:TypeArguments="x:String">[dtAddy.TableName]</OutArgument>

     

            </Assign.To>

     

            <Assign.Value>

     

              <InArgument x:TypeArguments="x:String">[sTableName]</InArgument>

     

            </Assign.Value>

     

          </Assign>

     

          <InvokeMethod sap:VirtualizedContainerService.HintSize="330,127" MethodName="Add">

     

            <InvokeMethod.TargetObject>

     

              <InArgument x:TypeArguments="sd:DataTableCollection">[dsReportSource.Tables]</InArgument>

     

            </InvokeMethod.TargetObject>

     

            <InArgument x:TypeArguments="sd:DataTable">[dtAddy]</InArgument>

     

          </InvokeMethod>

     

        </Sequence>

     

      </Sequence>

     

    </Activity>
    0
  • Ryan Cooney

    Hi Laura,

    You can do this by creating a new FeatureSet from the original one, that only includes the first feature. You'll need to add the "System.Linq" namespace you your imports tab, then use:

    New FeatureSet(fsAddy.Take(1))

    Take(int count) is a Linq Extension method that grabs the first n items from a collection http://msdn.microsoft.com/en-us/library/bb503062.aspx.

    --Ryan

    0

Please sign in to leave a comment.