<?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: Arcade Calculation Rule Increment Attribute Value in ArcGIS Utility Network Questions</title>
    <link>https://community.esri.com/t5/arcgis-utility-network-questions/arcade-calculation-rule-increment-attribute-value/m-p/1203336#M1946</link>
    <description>&lt;P&gt;Hi Luca - it might be worth including a small diagram of how your addresses connect up to your distribution boxes. E.g. if they have junction-junction association then you may be able to use the Arcade functions specific to Utility Network like&amp;nbsp;&lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#featuresetbyassociation" target="_self"&gt;FeatureSetByAssociation&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Aug 2022 15:55:36 GMT</pubDate>
    <dc:creator>jclarke</dc:creator>
    <dc:date>2022-08-16T15:55:36Z</dc:date>
    <item>
      <title>Arcade Calculation Rule Increment Attribute Value</title>
      <link>https://community.esri.com/t5/arcgis-utility-network-questions/arcade-calculation-rule-increment-attribute-value/m-p/1203169#M1942</link>
      <description>&lt;P&gt;Hey guys,&lt;/P&gt;&lt;P&gt;I am working on an attribute rule for the devices in my utility network.&lt;/P&gt;&lt;P&gt;I have 2 different assetgroups: Adresses and distribution boxes. One distribution box is able to supply 96 units. So whenever a new adress is added, the user has to fill an attribute "Number" which contains the amount of units at this adress. This works fine so far.&lt;/P&gt;&lt;P&gt;The Distribution Box also has an Attribute called "Number_Apartments" which surprisingly contains the amount of units at this box. Here is where the fun begins. When an adress with for example 5 units is added (Attribute "Number" is 5), I want to increment the "Number_Apartments"-value automatically by 5. Sadly i can't get this done.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any idea how to solve this?&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;Luca&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 10:27:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-utility-network-questions/arcade-calculation-rule-increment-attribute-value/m-p/1203169#M1942</guid>
      <dc:creator>Luca_Schikowski</dc:creator>
      <dc:date>2022-08-16T10:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Calculation Rule Increment Attribute Value</title>
      <link>https://community.esri.com/t5/arcgis-utility-network-questions/arcade-calculation-rule-increment-attribute-value/m-p/1203211#M1943</link>
      <description>&lt;P&gt;That is absolutely possible. Question: How do you get the distribution box that belongs to an address? Do you have a foreign key field? Have you built a relationship class? Do you use spatial relationship?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 12:48:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-utility-network-questions/arcade-calculation-rule-increment-attribute-value/m-p/1203211#M1943</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-08-16T12:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Calculation Rule Increment Attribute Value</title>
      <link>https://community.esri.com/t5/arcgis-utility-network-questions/arcade-calculation-rule-increment-attribute-value/m-p/1203217#M1944</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Calculation Attribute Rule on Addresses
// field: empty
// triggers: Insert, Update, Delete
// Exclude from application Evaluation

// if we're updating the address, but not changing the Number field, abort
if($editcontext.editType == "UPDATE" &amp;amp;&amp;amp; $feature.Number == $originalfeature.Number) { return }

// get the related distribution box
var box_name = $feature.box
var box_featuredataset = FeatureSetByName(...)
var box = First(Filter(box_featuredataset, "name = @box_name"))
if(box == null) { return } // no related  box found, abort

// get the current Apartment count and calculate the new one, according to our edit mode:
// Insert: add
// Delete: subtract
// Update: subtract old, add new
var apartments = box.Number_Apartments
var change = When(
    $editcontext.editType == "INSERT", $feature.Number,
    $editcontext.editType == "DELETE", -$feature.Number,
    $editcontext.editType == "UPDATE", -$originalfeature.Number + $feature.Number,
    0 // default value
)

// instead of returning a value, we return a dictionary that follows certain rules, see
// https://pro.arcgis.com/en/pro-app/2.9/help/data/geodatabases/overview/attribute-rule-dictionary-keywords.htm
return {
    "edit": [{
        "className": "Addresses",
        "updates": [{
            "globalID": box.GlobalID,//or "objectID": box.OBJECTID
            "attributes": {"Number_Apartments": apartments + change}
        }]
    }]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 11:29:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-utility-network-questions/arcade-calculation-rule-increment-attribute-value/m-p/1203217#M1944</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-08-17T11:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Calculation Rule Increment Attribute Value</title>
      <link>https://community.esri.com/t5/arcgis-utility-network-questions/arcade-calculation-rule-increment-attribute-value/m-p/1203281#M1945</link>
      <description>&lt;P&gt;Hi, my Adresses got an attribute called "box" which contains the name of the distribution box. My boxes got an attribute "name" which contains the exact same values as "box". I am using a Filter which returns all boxes with the adresses box-name:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;var box_filtered = Filter(box_featuredataset, "name = @box")&lt;/P&gt;&lt;P&gt;Actually i never heard of Relationship Classes before. I will take a look at it. Your code is understandable and seems to do excactly what I want. I just need some time to get into relationships and will reply here if I have any more questions.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you very much for your quick reply!&lt;BR /&gt;Have a nice day&lt;BR /&gt;Luca&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 14:44:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-utility-network-questions/arcade-calculation-rule-increment-attribute-value/m-p/1203281#M1945</guid>
      <dc:creator>Luca_Schikowski</dc:creator>
      <dc:date>2022-08-16T14:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Calculation Rule Increment Attribute Value</title>
      <link>https://community.esri.com/t5/arcgis-utility-network-questions/arcade-calculation-rule-increment-attribute-value/m-p/1203336#M1946</link>
      <description>&lt;P&gt;Hi Luca - it might be worth including a small diagram of how your addresses connect up to your distribution boxes. E.g. if they have junction-junction association then you may be able to use the Arcade functions specific to Utility Network like&amp;nbsp;&lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#featuresetbyassociation" target="_self"&gt;FeatureSetByAssociation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 15:55:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-utility-network-questions/arcade-calculation-rule-increment-attribute-value/m-p/1203336#M1946</guid>
      <dc:creator>jclarke</dc:creator>
      <dc:date>2022-08-16T15:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Calculation Rule Increment Attribute Value</title>
      <link>https://community.esri.com/t5/arcgis-utility-network-questions/arcade-calculation-rule-increment-attribute-value/m-p/1203651#M1947</link>
      <description>&lt;P&gt;So i tried using a relationship class but it failed with error code 160263:&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/2.9/tool-reference/tool-errors-and-warnings/160001-170000/tool-errors-and-warnings-160251-160275-160263.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/2.9/tool-reference/tool-errors-and-warnings/160001-170000/tool-errors-and-warnings-160251-160275-160263.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I understand the usage of relationship classes but it seems that its not the way how I can solve this.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 10:40:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-utility-network-questions/arcade-calculation-rule-increment-attribute-value/m-p/1203651#M1947</guid>
      <dc:creator>Luca_Schikowski</dc:creator>
      <dc:date>2022-08-17T10:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Calculation Rule Increment Attribute Value</title>
      <link>https://community.esri.com/t5/arcgis-utility-network-questions/arcade-calculation-rule-increment-attribute-value/m-p/1203664#M1948</link>
      <description>&lt;P&gt;Hmm... That seems like a very rare error. Either you used some wrong inputs or there's something funky with your data.&lt;/P&gt;&lt;P&gt;This is not the place to get into this, though. If you want to create relationship classes (they can be useful but are rarely (never?) really neccessary), I suggest asking for help in the &lt;A href="https://community.esri.com/t5/data-management/ct-p/data-management" target="_blank"&gt;Data Management - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can also just use the filter you already have in place, I updated the code in my other anser.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 11:30:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-utility-network-questions/arcade-calculation-rule-increment-attribute-value/m-p/1203664#M1948</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-08-17T11:30:36Z</dc:date>
    </item>
  </channel>
</rss>

