<?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: Use calculationRequired  to trigger updates in another feature in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/use-calculationrequired-to-trigger-updates-in/m-p/1656876#M45769</link>
    <description>&lt;P&gt;Thank you for pointing me in the right direction.&amp;nbsp; Here is the working version:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var id = $feature.Feature_Name
var out = FeatureSetByName($datastore, "STORMWATER.pipe_maintenance", ['globalid', 'assetid'], false)
var devices = Filter(out, "assetid= &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/354972"&gt;@ID&lt;/a&gt;")
var device = When(Count(devices) &amp;gt; 0, First(devices), Null)

if (typeof(device) == 'Feature') {
   return {
      'result': {'attributes': Dictionary('Event_Status', 'Success') }, 'edit': [{
         'className': 'STORMWATER.pipe_maintenance',
         'updates': [{ 'attributes': {'last_cleaned': $feature.Create_Date}, 'globalID': device.globalid }]
      }]
   }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the "edit" keyword to modify the target layer is a more direct approach, compared to my previous attempt trying to trigger a separate calculation rule on the target layer.&lt;/P&gt;&lt;P&gt;A couple clarifying questions:&lt;/P&gt;&lt;P&gt;In the above example, I pass a dictionary into the 'result' key that sets the 'Event_Status' field to 'Success'.&amp;nbsp; In this case, I do not need a result value.&amp;nbsp; Is the 'result' key word required?&amp;nbsp; Can I pass it an empty dictionary without issue?&lt;/P&gt;&lt;P&gt;When the script for an attribute rule is not working on an Enterprise branch service, it can be time consuming to explore fixes, having to disable and re-enable the service, etc.&amp;nbsp; Within the scripting window, I can use the Console() function to inspect example output.&amp;nbsp; Is there a way I can log these outputs to a file to inspect later?&amp;nbsp; I ended up packing any information I needed into the 'errorMessage' keyword, which I can inspect on a failure.&amp;nbsp; Is this the recommended way to debug an attribute rule?&lt;/P&gt;</description>
    <pubDate>Thu, 09 Oct 2025 20:53:19 GMT</pubDate>
    <dc:creator>ErikRose</dc:creator>
    <dc:date>2025-10-09T20:53:19Z</dc:date>
    <item>
      <title>Use calculationRequired  to trigger updates in another feature</title>
      <link>https://community.esri.com/t5/data-management-questions/use-calculationrequired-to-trigger-updates-in/m-p/1655291#M45759</link>
      <description>&lt;P&gt;We have a line layer representing stormwater pipes, and a table of related records containing information about individual inspections, cleanings and maintenance.&amp;nbsp; When a worker adds a new event to the related records, I want to trigger an attribute rule to fire on the line layer to update a field with the creation date of the most recent related record.&lt;/P&gt;&lt;P&gt;The attribute rule that I want to trigger on the line layer looks like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var all_events = FeatureSetByName($datastore, "STORMWATER.stormwater_events_20250926", ['Create_Date', 'Feature_Name'], false)
var id = $feature.assetid
var events = Filter(OrderBy(all_events, 'Create_Date DESC'), "Feature_Name= &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/354972"&gt;@ID&lt;/a&gt;")
var recent = First(events)
When(recent != Null, Date(recent.Create_Date), Null)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From a previous thread (&lt;A href="https://community.esri.com/t5/data-management-questions/attribute-rules-to-trigger-another-feature-class/td-p/1565736" target="_blank"&gt;Attribute Rules to trigger another feature class t... - Esri Community)&lt;/A&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/138089"&gt;@RobertKrisher&lt;/a&gt;&amp;nbsp;writes:&amp;nbsp;&lt;SPAN&gt;It is possible to force attribute rules to fire on other features when a feature is modified using the&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/attribute-rule-dictionary-keywords.htm#ESRI_SECTION1_4DC091DA6F984FB1BB03722FA6B48FE3" target="_blank" rel="noopener nofollow noreferrer"&gt;calculationRequired dictionary keyword&lt;/A&gt;&lt;SPAN&gt;.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure how to implement this advice.&amp;nbsp; So far, I have tried setting an attribute rule on the table of related records to run on insert and update.&amp;nbsp; But it does not work and I am not sure how to debug it.&amp;nbsp; Any tips?&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// the "asset id" field e.g. "SWGM-1002" in the related records

var id = $feature.Feature_Name

// Are variable names case sensitive here?  Is 'globalid' != 'GLOBALID'?

var out = FeatureSetByName($datastore, "pipe_maintenance", ['globalid', 'assetid'], false)

// The related records include outfall inspections (no pipe reference), so the filter can return Null
var devices = Filter(out, "assetid= &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/354972"&gt;@ID&lt;/a&gt;")
var device = When(Count(devices) &amp;gt; 0, First(devices), Null)

// Can I conditionally return here?
if (device != Null) {
   return {
      'calculationRequired': [{

          'className': "STORMWATER.pipe_maintenance",
          // Can I use the asset id, or only global ids?
          'globalIDs': [device] }]
   }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With this "attribute rule" in place, updates to the layer simply fail.&lt;/P&gt;&lt;P&gt;When a worker adds a new maintenance event, it creates a record with a creation date.&amp;nbsp; I want to update the pipe feature layer associated with the related record when this occurs, so that an attribute field in the pipe feature shows the most recent inspection date.&lt;/P&gt;&lt;P&gt;Thank you for your help,&lt;/P&gt;&lt;P&gt;Erik&lt;/P&gt;</description>
      <pubDate>Fri, 03 Oct 2025 20:23:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/use-calculationrequired-to-trigger-updates-in/m-p/1655291#M45759</guid>
      <dc:creator>ErikRose</dc:creator>
      <dc:date>2025-10-03T20:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: Use calculationRequired  to trigger updates in another feature</title>
      <link>https://community.esri.com/t5/data-management-questions/use-calculationrequired-to-trigger-updates-in/m-p/1655634#M45761</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/697140"&gt;@ErikRose&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Are you looking to have it setup so that when the related record is updated that the main feature will also update? Somethings to consider in your script.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;You can use either GlobalIDs or ObjectIDs as a means of updating another feature. You can use other ids to filter by but updates should only require an object id or global id.&lt;/LI&gt;&lt;LI&gt;I don't think you can force a calculation but rather set it up so that when there is a change to a feature, whether it be an update or insert, you can set the rule to trigger based on one of those conditions using the $editcontext.editType and specify 'INSERT' or 'UPDATE' triggers are identified.&lt;/LI&gt;&lt;LI&gt;If you want it to update another feature then I would recommend the following below.&lt;/LI&gt;&lt;/OL&gt;&lt;LI-CODE lang="javascript"&gt;// the "asset id" field e.g. "SWGM-1002" in the related records

var id = $feature.Feature_Name

// Are variable names case sensitive here?  Is 'globalid' != 'GLOBALID'?

var out = FeatureSetByName($datastore, "pipe_maintenance", ['globalid', 'assetid'], false)

// The related records include outfall inspections (no pipe reference), so the filter can return Null
var devices = Filter(out, "assetid= @ID")
var device = When(Count(devices) &amp;gt; 0, First(devices), Null)

// Can I conditionally return here?
if (typeof(device) == 'feature' {
   return {
      'result': {'attributes': Dictionary(fieldname,value) }, 'edit': [{
		  'className': "STORMWATER.pipe_maintenance",
		  "updates" : [{ 'attributes': {fieldname, fieldvalue},'globalID': device.globalid }]
	  }]
   }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 06 Oct 2025 20:28:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/use-calculationrequired-to-trigger-updates-in/m-p/1655634#M45761</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2025-10-06T20:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: Use calculationRequired  to trigger updates in another feature</title>
      <link>https://community.esri.com/t5/data-management-questions/use-calculationrequired-to-trigger-updates-in/m-p/1656876#M45769</link>
      <description>&lt;P&gt;Thank you for pointing me in the right direction.&amp;nbsp; Here is the working version:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var id = $feature.Feature_Name
var out = FeatureSetByName($datastore, "STORMWATER.pipe_maintenance", ['globalid', 'assetid'], false)
var devices = Filter(out, "assetid= &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/354972"&gt;@ID&lt;/a&gt;")
var device = When(Count(devices) &amp;gt; 0, First(devices), Null)

if (typeof(device) == 'Feature') {
   return {
      'result': {'attributes': Dictionary('Event_Status', 'Success') }, 'edit': [{
         'className': 'STORMWATER.pipe_maintenance',
         'updates': [{ 'attributes': {'last_cleaned': $feature.Create_Date}, 'globalID': device.globalid }]
      }]
   }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the "edit" keyword to modify the target layer is a more direct approach, compared to my previous attempt trying to trigger a separate calculation rule on the target layer.&lt;/P&gt;&lt;P&gt;A couple clarifying questions:&lt;/P&gt;&lt;P&gt;In the above example, I pass a dictionary into the 'result' key that sets the 'Event_Status' field to 'Success'.&amp;nbsp; In this case, I do not need a result value.&amp;nbsp; Is the 'result' key word required?&amp;nbsp; Can I pass it an empty dictionary without issue?&lt;/P&gt;&lt;P&gt;When the script for an attribute rule is not working on an Enterprise branch service, it can be time consuming to explore fixes, having to disable and re-enable the service, etc.&amp;nbsp; Within the scripting window, I can use the Console() function to inspect example output.&amp;nbsp; Is there a way I can log these outputs to a file to inspect later?&amp;nbsp; I ended up packing any information I needed into the 'errorMessage' keyword, which I can inspect on a failure.&amp;nbsp; Is this the recommended way to debug an attribute rule?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Oct 2025 20:53:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/use-calculationrequired-to-trigger-updates-in/m-p/1656876#M45769</guid>
      <dc:creator>ErikRose</dc:creator>
      <dc:date>2025-10-09T20:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: Use calculationRequired  to trigger updates in another feature</title>
      <link>https://community.esri.com/t5/data-management-questions/use-calculationrequired-to-trigger-updates-in/m-p/1657190#M45770</link>
      <description>&lt;P&gt;When possible, doing your initial development/testing in a local mobile geodatabase can speed up the process greatly. Another trick is to write as much of the code as possible using a popup expression (since it shares many of the same profiles/functions as attribute rules), this saves you having to bounce services, gives you access to console, and lets you test it out on different features.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Oct 2025 19:37:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/use-calculationrequired-to-trigger-updates-in/m-p/1657190#M45770</guid>
      <dc:creator>RobertKrisher</dc:creator>
      <dc:date>2025-10-10T19:37:02Z</dc:date>
    </item>
  </channel>
</rss>

