<?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 Create and Populate Related Record from Main Record on SAVE in ArcGIS Field Maps Questions</title>
    <link>https://community.esri.com/t5/arcgis-field-maps-questions/create-and-populate-related-record-from-main/m-p/1655973#M11565</link>
    <description>&lt;P&gt;I have a feature class of highway ramps and a related table that houses the unique field to create the relate and a couple other fields I am trying to automatically populate on save&lt;/P&gt;&lt;P&gt;Can I configure field maps to &lt;U&gt;Automatically&lt;/U&gt; create a new Related record on SAVE of the original record writing to a related table.&amp;nbsp; Thus creating a historical table of change over time..&lt;/P&gt;&lt;P&gt;Example:&amp;nbsp;&lt;BR /&gt;1. Ramp Status field on the Line Feature Class is OPEN&lt;BR /&gt;2. User clicks on the record and updates the status to CLOSED&lt;BR /&gt;3. I want to have a record created in the related table that pulls info from the Main Feature.&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ex.&amp;nbsp; The STATUS, USER, RAMPID, TIMESTAMP&lt;BR /&gt;&lt;BR /&gt;Where the user does NOT have to do anything but change the STATUS on the main feature and the related record is created automatically.&lt;/P&gt;&lt;P&gt;This would only create a new Record if and when the STATUS field was changed.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Oct 2025 19:16:42 GMT</pubDate>
    <dc:creator>kapalczynski</dc:creator>
    <dc:date>2025-10-07T19:16:42Z</dc:date>
    <item>
      <title>Create and Populate Related Record from Main Record on SAVE</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/create-and-populate-related-record-from-main/m-p/1655973#M11565</link>
      <description>&lt;P&gt;I have a feature class of highway ramps and a related table that houses the unique field to create the relate and a couple other fields I am trying to automatically populate on save&lt;/P&gt;&lt;P&gt;Can I configure field maps to &lt;U&gt;Automatically&lt;/U&gt; create a new Related record on SAVE of the original record writing to a related table.&amp;nbsp; Thus creating a historical table of change over time..&lt;/P&gt;&lt;P&gt;Example:&amp;nbsp;&lt;BR /&gt;1. Ramp Status field on the Line Feature Class is OPEN&lt;BR /&gt;2. User clicks on the record and updates the status to CLOSED&lt;BR /&gt;3. I want to have a record created in the related table that pulls info from the Main Feature.&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ex.&amp;nbsp; The STATUS, USER, RAMPID, TIMESTAMP&lt;BR /&gt;&lt;BR /&gt;Where the user does NOT have to do anything but change the STATUS on the main feature and the related record is created automatically.&lt;/P&gt;&lt;P&gt;This would only create a new Record if and when the STATUS field was changed.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Oct 2025 19:16:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/create-and-populate-related-record-from-main/m-p/1655973#M11565</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2025-10-07T19:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: Create and Populate Related Record from Main Record on SAVE</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/create-and-populate-related-record-from-main/m-p/1656018#M11568</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/633156"&gt;@kapalczynski&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You can definitely do this in Field Maps. You would simply need to configure the Field Calculation with a script similar to the one below.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var FiltValue = $feature.RAMPID
var Status = $feature.STATUS
var OrigStatus = $originalfeature.STATUS
var UpdteTble = FeatureSetByName($map,'&amp;lt;Name of table/featureclass&amp;gt;',['&amp;lt;fieldnames&amp;gt;'],False)
UpdteTble = Filter(UpdteTble,'RAMPID = @FiltValue')

/*
var Values = Dictionary('STATUS', $feature.STATUS, fieldB, ValueB, ... )
*/
var Defaults = { result: { attributes: {'STATUS': $feature.STATUS } } }
var Edits = []
if( OrigStatus == 'OPEN' &amp;amp;&amp;amp; Status == 'CLOSED' &amp;amp;&amp;amp; Count(UpdteTble)==0 ){
	var Changes = Dictionary('className','&amp;lt;TblName&amp;gt;')
	var TblDict = Dictionary() // Can use the same values in the values dictionary if the field names are the same
	Changes['adds'] = Dictionary('attributes',TblDict)
	Push( Edits, Changes )
	}
if( Count( Edits ) &amp;gt; 0 ){ Defaults['edit'] = Edits }
return Defaults&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 07 Oct 2025 20:52:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/create-and-populate-related-record-from-main/m-p/1656018#M11568</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2025-10-07T20:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create and Populate Related Record from Main Record on SAVE</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/create-and-populate-related-record-from-main/m-p/1656199#M11587</link>
      <description>&lt;P&gt;First off thank you..... very appreciated.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Would this calculate run after the save button or submit button to capture the new status that was selected?&lt;/LI&gt;&lt;LI&gt;What if I have 5 or 6 status values... how would that effect the script...&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;If I define the VALUES variable with multiple fields does that replace the DEFAULTS variable&lt;BR /&gt;&lt;BR /&gt;I can read this but confused on the workflow and how this is actually creating the record in the related table&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Wed, 08 Oct 2025 13:21:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/create-and-populate-related-record-from-main/m-p/1656199#M11587</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2025-10-08T13:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: Create and Populate Related Record from Main Record on SAVE</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/create-and-populate-related-record-from-main/m-p/1656225#M11589</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/633156"&gt;@kapalczynski&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You can look up the documentation &lt;A href="https://developers.arcgis.com/arcade/function-reference/" target="_blank" rel="noopener"&gt;ArcGIS Arcade&lt;/A&gt;&amp;nbsp;in addition to &lt;A href="https://www.esri.com/arcgis-blog/products/arcgis-pro/data-management/advanced-gdb-attribute-rules-editing-external-features-with-attribute-rules" target="_blank" rel="noopener"&gt;Advanced Editing&lt;/A&gt; to help you get a better understanding of what the script is doing.&lt;/P&gt;&lt;P&gt;Here are my answers to your questsions:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN&gt;The script above will trigger every time some hits submit and so long as whatever conditions are met.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;If you have multiple status types but you simply want to update the related record, then you would only need to have it to that if the record already exists then it will simply get updated. Updates in arcade look like the code below.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;LI-CODE lang="javascript"&gt;var E = { 
	'edits':[{ 
		'className':'&amp;lt;featureclassname&amp;gt;',
		'updates':[{
			'OBJECTID': $feature.RelObjID,
			'attributes': Dictionary('RelFldA','Value','RelFldB','...')//If fields match then use the same as the original
			}]
		}]
	}&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;Yes. The key is that the fields in one record must be mapped accordingly, otherwise the edits will not apply. I use Defaults as an example variable. You can replace it with anything that works for you.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The script above is more of a general example but you can configure it to work however you like. Just make sure that the formatting is done correctly or the variables, fields, etc are the correct ones.&lt;/P&gt;&lt;P&gt;If you need to the get the object id of the related record then change the script above to look like the one below.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var FiltValue = $feature.RAMPID
var Status = $feature.STATUS
var OrigStatus = $originalfeature.STATUS
var UpdteTble = FeatureSetByName($map,'&amp;lt;Name of table/featureclass&amp;gt;',['&amp;lt;fieldnames&amp;gt;'],False)
UpdteTble = Filter(UpdteTble,'RAMPID = @FiltValue')

/*
var Values = Dictionary('STATUS', $feature.STATUS, fieldB, ValueB, ... )
*/
var Defaults = { result: { attributes: {'STATUS': $feature.STATUS } } }
var Edits = []
if( OrigStatus == 'OPEN' &amp;amp;&amp;amp; Status == 'CLOSED' ){
	var Changes = Dictionary('className','&amp;lt;TblName&amp;gt;')
	var TblDict = Dictionary() // Can use the same values in the values dictionary if the field names are the same
	if( Count(UpdteTble)==0 ){ 
		Changes['adds'] = Dictionary('attributes',TblDict)
		}
	else if( Count(UpdteTble)==1 ){ 
		var OID = First(UpdteTble).OBJECTID
		Changes['updates'] = Dictionary('OBJECTID',OID,'attributes',TblDict)
		}
	Push( Edits, Changes )
	}
if( Count( Edits ) &amp;gt; 0 ){ Defaults['edit'] = Edits }
return Defaults&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Oct 2025 14:31:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/create-and-populate-related-record-from-main/m-p/1656225#M11589</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2025-10-08T14:31:02Z</dc:date>
    </item>
  </channel>
</rss>

