<?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: Look-up Selected Attribute Field Error in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/look-up-selected-attribute-field-error/m-p/1146565#M7824</link>
    <description>&lt;P&gt;You can add "async" to "var mukeys = await LookupMukey();" calling method like this:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public async voif Your_Method()
{
    var mukeys = await LookupMukey();
}&lt;/LI-CODE&gt;&lt;P&gt;or change LookupMukey method calling to:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var mukeys = LookupMukey().Result;&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 22 Feb 2022 17:08:41 GMT</pubDate>
    <dc:creator>GKmieliauskas</dc:creator>
    <dc:date>2022-02-22T17:08:41Z</dc:date>
    <item>
      <title>Look-up Selected Attribute Field Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/look-up-selected-attribute-field-error/m-p/1146338#M7815</link>
      <description>&lt;P&gt;I am trying to return a list of selected feature attribute field, "mukey" from a feature class, "MUPOLYGON". I tried to look-up the mukey using the GetTable() method and creating a mukey list. However, I am getting an error that says cannot convert a Task to a string parameter when I tried to use the mukey list as a parameter for another method. I have the following questions:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. What is a light weight method to obtain a mukey list from the selected feature field, mukey?&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. How do I resolve the conversion error?&amp;nbsp;&lt;/P&gt;&lt;P&gt;public async Task LookupMukey()&lt;BR /&gt;{&lt;BR /&gt;var mukeys = new List&amp;lt;string&amp;gt;();&lt;BR /&gt;var MV = MapView.Active;&lt;BR /&gt;int mukeyCount = 0;&lt;BR /&gt;var SelectionLayer = MV.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().Where(fl =&amp;gt; fl.Name.Contains("SelectionLayer")).FirstOrDefault();&lt;/P&gt;&lt;P&gt;await QueuedTask.Run(() =&amp;gt;&lt;BR /&gt;{&lt;BR /&gt;using (var SelectionTable = SelectionLayer.GetTable())&lt;BR /&gt;{&lt;BR /&gt;using (var rowCursor = SelectionTable.Search())&lt;BR /&gt;{&lt;BR /&gt;while (rowCursor.MoveNext())&lt;BR /&gt;{&lt;BR /&gt;using (Row row = rowCursor.Current)&lt;BR /&gt;{&lt;BR /&gt;var mukey = Convert.ToString(row["mukey"]);&lt;BR /&gt;mukeys.Add(mukey);&lt;BR /&gt;mukeyCount++;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;return mukeys;&lt;BR /&gt;});&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Using the mukey list as a parameter for another method:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Process.ChorizonData(mukeys,"awc_l", "awc_r", "awc_h", inputPath);&amp;nbsp; //error occurs here at mukey&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 22 Feb 2022 04:34:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/look-up-selected-attribute-field-error/m-p/1146338#M7815</guid>
      <dc:creator>ThiPham12</dc:creator>
      <dc:date>2022-02-22T04:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: Look-up Selected Attribute Field Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/look-up-selected-attribute-field-error/m-p/1146355#M7819</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Your function must be like this :&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        public async Task&amp;lt;List&amp;lt;string&amp;gt;&amp;gt; LookupMukey()
        {
            var mukeys = new List&amp;lt;string&amp;gt;();
            var MV = MapView.Active;
            int mukeyCount = 0;
            var SelectionLayer = MV.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().Where(fl =&amp;gt; fl.Name.Contains("SelectionLayer")).FirstOrDefault();

            await QueuedTask.Run(() =&amp;gt;
            {
                using (var SelectionTable = SelectionLayer.GetTable())
                {
                    using (var rowCursor = SelectionTable.Search())
                    {
                        while (rowCursor.MoveNext())
                        {
                            using (Row row = rowCursor.Current)
                            {
                                var mukey = Convert.ToString(row["mukey"]);
                                mukeys.Add(mukey);
                                mukeyCount++;
                            }
                        }
                    }
                }
            });
            return mukeys;
        }&lt;/LI-CODE&gt;&lt;P&gt;And call to function:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var mukeys = await LookupMukey();&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 22 Feb 2022 06:14:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/look-up-selected-attribute-field-error/m-p/1146355#M7819</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2022-02-22T06:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: Look-up Selected Attribute Field Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/look-up-selected-attribute-field-error/m-p/1146553#M7822</link>
      <description>&lt;P&gt;Thanks for your help Gintautas! When I tried to call the function, I am getting an error that says, "CS4034: The await operator can only be used with an async lambda expression. Consider marking this lambda expression with the async modifier." Where do I add the async modifier to the lambda expression?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this right? await QueuedTask.Run(async() =&amp;gt;...&amp;nbsp; //error: lack await operator&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Feb 2022 16:47:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/look-up-selected-attribute-field-error/m-p/1146553#M7822</guid>
      <dc:creator>ThiPham12</dc:creator>
      <dc:date>2022-02-22T16:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: Look-up Selected Attribute Field Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/look-up-selected-attribute-field-error/m-p/1146565#M7824</link>
      <description>&lt;P&gt;You can add "async" to "var mukeys = await LookupMukey();" calling method like this:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public async voif Your_Method()
{
    var mukeys = await LookupMukey();
}&lt;/LI-CODE&gt;&lt;P&gt;or change LookupMukey method calling to:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var mukeys = LookupMukey().Result;&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 22 Feb 2022 17:08:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/look-up-selected-attribute-field-error/m-p/1146565#M7824</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2022-02-22T17:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: Look-up Selected Attribute Field Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/look-up-selected-attribute-field-error/m-p/1148289#M7849</link>
      <description>&lt;P&gt;Hi Gintautas,&amp;nbsp;&lt;/P&gt;&lt;P&gt;What if I am calling the LookupMukey method in a ICommand event handler? How should I call the LookupMukey()? Please see the example below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;//within a public ICommand CmdRun binded to a Run button&lt;/P&gt;&lt;P&gt;AllProcesses Process = new AllProcesses();&lt;/P&gt;&lt;P&gt;var mukeys = await Process.LookupMukey();&amp;nbsp; &amp;nbsp; //error occurs here&lt;/P&gt;&lt;P&gt;//codes below - calling multiple methods and passing the list of mukeys as one of the parameters&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Feb 2022 22:41:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/look-up-selected-attribute-field-error/m-p/1148289#M7849</guid>
      <dc:creator>tzz_12</dc:creator>
      <dc:date>2022-02-26T22:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: Look-up Selected Attribute Field Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/look-up-selected-attribute-field-error/m-p/1149057#M7864</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;If I understand right, it must be like this:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        protected XViewModel()
        {
            _CommandX = new RelayCommand(() =&amp;gt; CmdX(), true);
        }

        private ICommand _CommandX;
        public ICommand CommandX
        {
            get { return _CommandX; }
        }

        /// &amp;lt;summary&amp;gt;
        /// Execute the X command
        /// &amp;lt;/summary&amp;gt;
        private async void CmdX()
        {
		AllProcesses Process = new AllProcesses();
		var mukeys = await Process.LookupMukey();
		//codes below - calling multiple methods and passing the list of mukeys as one of the parameters
        }

	// or

        private void CmdX()
        {
		AllProcesses Process = new AllProcesses();
		var mukeys = Process.LookupMukey().Result;
		//codes below - calling multiple methods and passing the list of mukeys as one of the parameters
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 01 Mar 2022 13:32:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/look-up-selected-attribute-field-error/m-p/1149057#M7864</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2022-03-01T13:32:28Z</dc:date>
    </item>
  </channel>
</rss>

