<?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: Getting field map to update at runtime? in ModelBuilder Questions</title>
    <link>https://community.esri.com/t5/modelbuilder-questions/getting-field-map-to-update-at-runtime/m-p/1555455#M4032</link>
    <description>&lt;P&gt;Dang, sorry to see that no one replied here because I'm having a very similar issue. Need to interate through pairs of FC and merge them, but each pair may or may not have a schema that's different from its predecessor/follower. Trying to figure out how I can code a 'merge' tool allows me to 'reset field mappings' each iteration. Then, I could import it back into Pro as a custom script tool. Unfortunately, my python is only good enough to be dangerous rather than considered fluent.&lt;/P&gt;</description>
    <pubDate>Tue, 05 Nov 2024 16:07:04 GMT</pubDate>
    <dc:creator>mbramos</dc:creator>
    <dc:date>2024-11-05T16:07:04Z</dc:date>
    <item>
      <title>Getting field map to update at runtime?</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/getting-field-map-to-update-at-runtime/m-p/868165#M1007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm having quite a time with this one. I've built a model doing some linear/location referencing geoprocessing. It works fine, other than the fact that I need to run multiple feature classes through it, and there are two points within the model that I need the field maps to reset to default at runtime (table to table and append events). I've searched endlessly for a solution to this - and have mostly been referencing this thread:&amp;nbsp;&lt;A href="https://community.esri.com/thread/214904" target="_blank"&gt;Field Mappings variable as a parameter not working in 10.5.1&lt;/A&gt;&amp;nbsp;. I actually got the table to table field map to reset using this method&amp;nbsp;- calculate value to a field mappings object. Here is my code for that one:&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;Expression&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
getEvents&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"%JoinTable%"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

Code&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;getEvents&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;intable&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            fms &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;FieldMappings&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

            fms&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;removeAll&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
            fms&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;addTable&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;intable&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
            &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; fms‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, when I try to do the exact same thing for the Append Events step, it fails with errors 000622 - parameters not valid and 000735 - Field map: value is required. I also tried this code for this step, which produced the same error.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;Expression&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; 
getEvents&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"%TableTable%"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"%PODS Line Events%"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 
Code&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;getEvents&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;intable&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; target&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            fms &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;FieldMappings&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
            tfields &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListFields&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;target&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
            tfnames &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;f&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; f &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; tfields&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
            
            fms&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;removeAll&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
            fms&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;addTable&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;intable&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
            
            &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; field &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; fms&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;fields&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
                        &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;not&lt;/SPAN&gt; field&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; tfnames&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
                                    fmindex &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; fms&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;findFieldMapIndex&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;field&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
                                    fms&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;removeFieldMap&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fmindex&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
            &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; fms&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;/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;I also tried just adding the target table as the input, since Append Events just needs the schemas to match, and I also tried a few other combinations, but I cant seem to get it to work. Apologies in advance, my python knowledge is very limited to nonexistent. Hoping someone can help shed some light on this. I'm using ArcPro 2.4, also attaching some screenshots to show how they are kind of set up.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:48:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/getting-field-map-to-update-at-runtime/m-p/868165#M1007</guid>
      <dc:creator>lah</dc:creator>
      <dc:date>2021-12-12T10:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: Getting field map to update at runtime?</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/getting-field-map-to-update-at-runtime/m-p/1555455#M4032</link>
      <description>&lt;P&gt;Dang, sorry to see that no one replied here because I'm having a very similar issue. Need to interate through pairs of FC and merge them, but each pair may or may not have a schema that's different from its predecessor/follower. Trying to figure out how I can code a 'merge' tool allows me to 'reset field mappings' each iteration. Then, I could import it back into Pro as a custom script tool. Unfortunately, my python is only good enough to be dangerous rather than considered fluent.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 16:07:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/getting-field-map-to-update-at-runtime/m-p/1555455#M4032</guid>
      <dc:creator>mbramos</dc:creator>
      <dc:date>2024-11-05T16:07:04Z</dc:date>
    </item>
  </channel>
</rss>

