<?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: Execute SaveEditsCommand in OnCreateFeature edit event creates another feature in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/execute-saveeditscommand-in-oncreatefeature-edit/m-p/328121#M8532</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your solution works perfectly.&lt;/P&gt;&lt;P&gt;I can't utilize an identity field in the database to increment the numbers because the case number is a text concatenation of&amp;nbsp;the year and a sequence number which starts over at the beginning every year (like 18-006).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help Sean!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Jan 2018 15:58:28 GMT</pubDate>
    <dc:creator>HarlanMarshall</dc:creator>
    <dc:date>2018-01-03T15:58:28Z</dc:date>
    <item>
      <title>Execute SaveEditsCommand in OnCreateFeature edit event creates another feature</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/execute-saveeditscommand-in-oncreatefeature-edit/m-p/328119#M8530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Working with ArcGIS Desktop 10.5.1 and .NET SDK. Building ArcMap add-in extension. I'm trying to cause a newly created feature to be saved programatically as the last operation&amp;nbsp;of the OnCreateFeature edit event. The problem I'm having is that when the save edit command completes, another feature is created and the OnCreateFeature event is fired again. I do not understand what is causing another feature to be created. Here's the important parts of my OnCreateFeature event handler:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;private&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;m_editEvents_OnCreateFeature&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;ESRI&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ArcGIS&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Geodatabase&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;IObject obj&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
IFeature pFeature &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; obj &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; IFeature&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;// Set feature case number and other stuff...&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;// Save the newly created feature so that the feature and case number is commited&lt;/SPAN&gt;
UID pUID &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;new&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;UID&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
pUID&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Value &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"{59D2AFD2-9EA2-11D1-9165-0080C718DF97}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;// esriEditor.SaveEditsCommand &lt;/SPAN&gt;
ICommandItem pCmdItem &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; ArcMap&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Application&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Document&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CommandBars&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Find&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pUID&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;false&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;false&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
pCmdItem&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Execute&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know that the SaveEditsCommand internally executes StopEditing and StartEditing. However, I do not see why another feature is created and goes into endless loop (create, save, create, save, on and on).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there is a better way to accomplish saving automatically on creation, I would appreciate greatly finding out how to do it.&lt;/P&gt;&lt;P&gt;The reason I need this to happen is to commit the feature with its calculated case number to the geodatabase instantly so that other concurrent editors can get the next available sequential number from the feature class itself.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:32:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/execute-saveeditscommand-in-oncreatefeature-edit/m-p/328119#M8530</guid>
      <dc:creator>HarlanMarshall</dc:creator>
      <dc:date>2021-12-11T15:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: Execute SaveEditsCommand in OnCreateFeature edit event creates another feature</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/execute-saveeditscommand-in-oncreatefeature-edit/m-p/328120#M8531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, the save edits command will fire the events again if its called from within one.&lt;/P&gt;&lt;P&gt;Use the workspaceedit methods to do the save.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;private&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;OnCreateFeature&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;IObject obj&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;//do something and save?&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; pUID &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;new&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;UID&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pUID&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Value &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"{59D2AFD2-9EA2-11D1-9165-0080C718DF97}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;// esriEditor.SaveEditsCommand &lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; pCmdItem &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; ArcMap&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Application&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Document&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CommandBars&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Find&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pUID&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;false&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;false&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;//pCmdItem.Execute();&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; ws &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; ArcMap&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Editor&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;EditWorkspace &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; IWorkspaceEdit&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ws&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;StopEditing&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;true&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ws&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;StartEditing&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;true&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you're after sequential numbers from a DBMS you can also look into a sequence generator, which will be more efficient than saving edits and subsequent table scans to find the highest number.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:33:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/execute-saveeditscommand-in-oncreatefeature-edit/m-p/328120#M8531</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T15:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: Execute SaveEditsCommand in OnCreateFeature edit event creates another feature</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/execute-saveeditscommand-in-oncreatefeature-edit/m-p/328121#M8532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your solution works perfectly.&lt;/P&gt;&lt;P&gt;I can't utilize an identity field in the database to increment the numbers because the case number is a text concatenation of&amp;nbsp;the year and a sequence number which starts over at the beginning every year (like 18-006).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help Sean!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jan 2018 15:58:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/execute-saveeditscommand-in-oncreatefeature-edit/m-p/328121#M8532</guid>
      <dc:creator>HarlanMarshall</dc:creator>
      <dc:date>2018-01-03T15:58:28Z</dc:date>
    </item>
  </channel>
</rss>

