<?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 Calculation attribute rule fails for online map but works with offline map in ArcGIS Field Maps Questions</title>
    <link>https://community.esri.com/t5/arcgis-field-maps-questions/calculation-attribute-rule-fails-for-online-map/m-p/1127682#M2120</link>
    <description>&lt;P data-unlink="true"&gt;&lt;FONT size="3"&gt;I am us&lt;/FONT&gt;ing Field Maps to collect building inspection records to a standalone table by tapping on a feature in a related building layer. (See&amp;nbsp;&lt;A href="https://doc.arcgis.com/en/field-maps/ios/help/inspect.htm#ESRI_SECTION1_08FD3A4D011B44DF926EC29DC7B3B60E" target="_blank" rel="noopener"&gt;Inspect—Add a related report&lt;/A&gt;.) The inspection table and building feature class are both stored in an enterprise geodatabase. I have created &lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/calculation-attribute-rules.htm" target="_self"&gt;calculation attribute rules&lt;/A&gt; in ArcGIS Pro to automatically copy certain attributes&amp;nbsp;to an inspection record from its related building feature when the inspection is collected.&lt;/P&gt;&lt;P data-unlink="true"&gt;This process works when collecting inspections through an offline map area in Field Maps: once the edits are synced, the desired attributes automatically get copied over. However, when collecting in Field Maps through an &lt;STRONG&gt;online&lt;/STRONG&gt; map, the attributes do not get copied over.&lt;/P&gt;&lt;P data-unlink="true"&gt;Here is an example of the kind of script expression I am using for my attribute rules. In this case, the rule copies the&lt;FONT face="courier new,courier" size="3"&gt; Town &lt;/FONT&gt;attribute from the related building to an inspection record.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Don't change anything unless a `Building_ID` was added or modified
if ($originalFeature.Building_ID == $feature.Building_ID) return $feature.Town;

var relatedBuilding = FeatureSetByRelationshipName(
  $feature,
  "MyEnterpriseGDB.User.Building_Inspection_RelClass",
  ["Town"],
  false
);

// Don't change anything if a related building was not found
if (Count(relatedBuilding) == 0) {
  return $feature.Town;
}

return First(relatedBuilding).Town;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The attribute rule is created as follows, wh&lt;FONT size="3"&gt;ere &lt;FONT face="courier new,courier"&gt;script_expression&lt;/FONT&gt; is t&lt;/FONT&gt;he above block.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.management.AddAttributeRule(
    in_table=inspection_table,
    name="CopyBuildingTown",
    type="CALCULATION",
    script_expression=script_expression,
    triggering_events=["INSERT", "UPDATE"],
    field="Town",
    exclude_from_client_evaluation="EXCLUDE",
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Software versions:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;ArcGIS Pro 2.9.0&lt;/LI&gt;&lt;LI&gt;ArcGIS Enterprise 10.8.1&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Any suggestions or ideas as to what the problem might be would be appreciated!&lt;/P&gt;</description>
    <pubDate>Mon, 20 Dec 2021 17:56:21 GMT</pubDate>
    <dc:creator>skykasko</dc:creator>
    <dc:date>2021-12-20T17:56:21Z</dc:date>
    <item>
      <title>Calculation attribute rule fails for online map but works with offline map</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/calculation-attribute-rule-fails-for-online-map/m-p/1127682#M2120</link>
      <description>&lt;P data-unlink="true"&gt;&lt;FONT size="3"&gt;I am us&lt;/FONT&gt;ing Field Maps to collect building inspection records to a standalone table by tapping on a feature in a related building layer. (See&amp;nbsp;&lt;A href="https://doc.arcgis.com/en/field-maps/ios/help/inspect.htm#ESRI_SECTION1_08FD3A4D011B44DF926EC29DC7B3B60E" target="_blank" rel="noopener"&gt;Inspect—Add a related report&lt;/A&gt;.) The inspection table and building feature class are both stored in an enterprise geodatabase. I have created &lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/calculation-attribute-rules.htm" target="_self"&gt;calculation attribute rules&lt;/A&gt; in ArcGIS Pro to automatically copy certain attributes&amp;nbsp;to an inspection record from its related building feature when the inspection is collected.&lt;/P&gt;&lt;P data-unlink="true"&gt;This process works when collecting inspections through an offline map area in Field Maps: once the edits are synced, the desired attributes automatically get copied over. However, when collecting in Field Maps through an &lt;STRONG&gt;online&lt;/STRONG&gt; map, the attributes do not get copied over.&lt;/P&gt;&lt;P data-unlink="true"&gt;Here is an example of the kind of script expression I am using for my attribute rules. In this case, the rule copies the&lt;FONT face="courier new,courier" size="3"&gt; Town &lt;/FONT&gt;attribute from the related building to an inspection record.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Don't change anything unless a `Building_ID` was added or modified
if ($originalFeature.Building_ID == $feature.Building_ID) return $feature.Town;

var relatedBuilding = FeatureSetByRelationshipName(
  $feature,
  "MyEnterpriseGDB.User.Building_Inspection_RelClass",
  ["Town"],
  false
);

// Don't change anything if a related building was not found
if (Count(relatedBuilding) == 0) {
  return $feature.Town;
}

return First(relatedBuilding).Town;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The attribute rule is created as follows, wh&lt;FONT size="3"&gt;ere &lt;FONT face="courier new,courier"&gt;script_expression&lt;/FONT&gt; is t&lt;/FONT&gt;he above block.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.management.AddAttributeRule(
    in_table=inspection_table,
    name="CopyBuildingTown",
    type="CALCULATION",
    script_expression=script_expression,
    triggering_events=["INSERT", "UPDATE"],
    field="Town",
    exclude_from_client_evaluation="EXCLUDE",
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Software versions:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;ArcGIS Pro 2.9.0&lt;/LI&gt;&lt;LI&gt;ArcGIS Enterprise 10.8.1&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Any suggestions or ideas as to what the problem might be would be appreciated!&lt;/P&gt;</description>
      <pubDate>Mon, 20 Dec 2021 17:56:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/calculation-attribute-rule-fails-for-online-map/m-p/1127682#M2120</guid>
      <dc:creator>skykasko</dc:creator>
      <dc:date>2021-12-20T17:56:21Z</dc:date>
    </item>
  </channel>
</rss>

