<?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: Using Arcade to edit an attribute in another feature in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/using-arcade-to-edit-an-attribute-in-another/m-p/1271309#M67136</link>
    <description>&lt;P&gt;I think the verification is run on a default&amp;nbsp; object (new object with all default values). Don't quote me on this...&lt;/P&gt;&lt;P&gt;Your default value for OUT_OF_SERVICE is probably null, so the rule doesn't enter the if block in line 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This might also be why you're no getting the updates you expect. In its current state, the rule will only update the parent feature if&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;OUT_OF_SERVICE is not empty (it accepts any value) and&lt;/LI&gt;&lt;LI&gt;DATEWORK is empty&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;If OUT_OF_SERVICE is empty or DATEWORK is not empty, the rule will not update the parent feature. Is that the expected behavior?&lt;/P&gt;</description>
    <pubDate>Fri, 24 Mar 2023 13:06:51 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2023-03-24T13:06:51Z</dc:date>
    <item>
      <title>Using Arcade to edit an attribute in another feature</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-arcade-to-edit-an-attribute-in-another/m-p/1270941#M67077</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;So what I am doing is trying to update the Inspection Status (INSP_STATUS) of a feature, based on an inspection records that is getting populated in a separate table....both in the same database.&lt;/P&gt;&lt;P&gt;So far this is what I have setup as a "Validation" rule on the table the inspections get saved in.&amp;nbsp; So if the newly created inspection meets the criteria to be marked as "Out of Service" I need to update the INSP_STATUS field of the feature to "OOS".&amp;nbsp; The inspection/feature have a common field of FACILITYID.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I 'verify' the code I get the green check, but when I try to save the attribute rule, I get a red mark and it tells me I need to use a GlobalID.&amp;nbsp; Is there a way to do this without using the GlobalID??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if (($feature.OUT_OF_SERVICE != null) &amp;amp;&amp;amp; ($feature.DATEWORK == null))&lt;BR /&gt;{&lt;BR /&gt;//update INSP_STATUS in the hydrant layer to OOS&lt;BR /&gt;return&lt;BR /&gt;{&lt;BR /&gt;'edit': [{&lt;BR /&gt;'classname' : 'WAT_Hydrant',&lt;BR /&gt;'updates' : [{&lt;BR /&gt;'FACILITYID' : $feature.FACILITYID,&lt;BR /&gt;'attributes' : {&lt;BR /&gt;'INSP_STATUS' : 'OOS'&lt;BR /&gt;}&lt;BR /&gt;}]&lt;BR /&gt;}]&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:59:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-arcade-to-edit-an-attribute-in-another/m-p/1270941#M67077</guid>
      <dc:creator>BrianBulla</dc:creator>
      <dc:date>2023-03-23T15:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using Arcade to edit an attribute in another feature</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-arcade-to-edit-an-attribute-in-another/m-p/1271016#M67084</link>
      <description>&lt;P&gt;&lt;SPAN&gt;To post code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1677736512957.png" style="width: 546px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64138iBB0E7839D9513E0F/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_0-1677736512957.png" alt="JohannesLindner_0-1677736512957.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1677736529803.png" style="width: 661px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64139i1EE5AE3E3AEE8247/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_1-1677736529803.png" alt="JohannesLindner_1-1677736529803.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;So far this is what I have setup as a "Validation" rule on the table the inspections get saved in&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;It has to be a Calculation Attribute Rule.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Is there a way to do this without using the GlobalID??&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;No. Attribute Rules need GlobalIDs to work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You apparently already found an example of how to update another table. But take a look at the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/attribute-rule-dictionary-keywords.htm" target="_blank" rel="noopener"&gt;official documentation for the return dictionary&lt;/A&gt;. It expects certain keys, and FACILITYID is not one of them. You have to supply the objectID or globalID of the feature you want to edit.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Something like this should work (remember to enable GlobalID):&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Calculation Attribute Rule on the inspection table
// field: leave empty
// triggers: insert
// exclude from application evaluation

if (($feature.OUT_OF_SERVICE != null) &amp;amp;&amp;amp; ($feature.DATEWORK == null)) {
    // get the hydrant
    var hydrants = FeaturesetByName($datastore, 'WAT_Hydrant', ['FACILITYID', 'ObjectID'], false)
    var facility_id = $feature.FACILITYID
    var hydrant = First(Filter(hydrants, 'FACILITYID = @facility_id'))
    // abort if no hydrant was found
    if(hydrant == null) { return }
    //update INSP_STATUS in the hydrant layer to OOS
    return {
        'edit': [{
            'classname' : 'WAT_Hydrant',
            'updates' : [{
                'objectID': hydrant.ObjectID,
                'attributes' : {'INSP_STATUS' : 'OOS'}
            }]
        }]
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 17:45:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-arcade-to-edit-an-attribute-in-another/m-p/1271016#M67084</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-03-23T17:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using Arcade to edit an attribute in another feature</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-arcade-to-edit-an-attribute-in-another/m-p/1271086#M67094</link>
      <description>&lt;P&gt;Hi Jonannes.&lt;/P&gt;&lt;P&gt;Ok, so that error message I was getting was becuase I didn't have a GlobalID on my inspection table, so I added that, updated the code as per your sample above, and it kind of sort of works.&amp;nbsp; I don't get any errors, but I also don't get INSP_STATUS to update.&lt;BR /&gt;&lt;BR /&gt;I've insert a console statement to try and do some debugging, but where to the console statements come out?&amp;nbsp; I can't seem to find a console window or anything in Pro.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 19:18:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-arcade-to-edit-an-attribute-in-another/m-p/1271086#M67094</guid>
      <dc:creator>BrianBulla</dc:creator>
      <dc:date>2023-03-23T19:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using Arcade to edit an attribute in another feature</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-arcade-to-edit-an-attribute-in-another/m-p/1271251#M67115</link>
      <description>&lt;P&gt;The console messages are visible after you verified your expression. There should be green text like "Show Messages" or something.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 07:07:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-arcade-to-edit-an-attribute-in-another/m-p/1271251#M67115</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-03-24T07:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using Arcade to edit an attribute in another feature</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-arcade-to-edit-an-attribute-in-another/m-p/1271298#M67131</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;.&amp;nbsp; Yes, I have seen that before, but in this case when I run the "Verify" it is not coming up.&amp;nbsp; Here is my code where I inserted the console message, so it should come up everytime.&lt;/P&gt;&lt;P&gt;But what is happening when I hit this verify?&amp;nbsp; What is this running against?&amp;nbsp; There are records in my table this rule is getting set on, but how does it (or I) know what record is being used when I hit the verify button?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;if (($feature.OUT_OF_SERVICE != null) &amp;amp;&amp;amp; ($feature.DATEWORK == null)) {
    // get the hydrant
    var hydrants = FeaturesetByName($datastore, 'WAT_Hydrant', ['FACILITYID', 'ObjectID'], false)
    var facility_id = $feature.FACILITYID
    var hydrant = First(Filter(hydrants, 'FACILITYID = @facility_id'))
    
    console(hydrant.ObjectID)

    // abort if no hydrant was found
    if(hydrant == null) { return }

    


    //update INSP_STATUS in the hydrant layer to OOS
    return {
        'edit': [{
            'classname' : 'WAT_Hydrant',
            'updates' : [{
                'objectID': hydrant.ObjectID,
                'attributes' : {'INSP_STATUS' : 'OOS'}
            }]
        }]
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 12:54:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-arcade-to-edit-an-attribute-in-another/m-p/1271298#M67131</guid>
      <dc:creator>BrianBulla</dc:creator>
      <dc:date>2023-03-24T12:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using Arcade to edit an attribute in another feature</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-arcade-to-edit-an-attribute-in-another/m-p/1271308#M67135</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OK, so an update here...&lt;/P&gt;&lt;P&gt;I made some code changes and it appears that when you run the "Verify" it is using the first record in the table, not the last.&amp;nbsp; So that definitely helps to know when troubleshooting.&lt;/P&gt;&lt;P&gt;So if I edit that first record, I seem to get the results I am expecting in 'verify' mode, but when adding a new record, I do not see any change to the hydrant INSP_STATUS.&amp;nbsp; Any ideas what might be going on??&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// Calculation Attribute Rule on the inspection table
// field: leave empty
// triggers: insert
// exclude from application evaluation

console("TEST")

// get the hydrant feature
var hydrants = FeaturesetByName($datastore, 'WAT_Hydrant', ['FACILITYID', 'ObjectID'], false);
var facility_id = $feature.FACILITYID;
var hydrant = First(Filter(hydrants, 'FACILITYID = @facility_id'));

//Check for an Out of Service (OOS) inspection first
if (($feature.OUT_OF_SERVICE != null) &amp;amp;&amp;amp; ($feature.DATEWORK == null)) 
{
    console("OOS")

    // abort if no hydrant was found
    if(hydrant == null) { return };

    //update INSP_STATUS in the hydrant layer to OOS
    return {
        'edit': [{
            'classname' : 'WAT_Hydrant',
            'updates' : [{
                'objectID': hydrant.ObjectID,
                'attributes' : {'INSP_STATUS' : 'OOS'}
                        }]
                }]
           };
}

 
//Next, check to see if it's a Work Required (WR) inspection
if ((($feature.HYDRANT_OPERATION != null) || ($feature.OPERATING_NUT != null) || ($feature.NOZZLE_CAPS != null) || ($feature.FLANGES != null) || ($feature.SECONDARY_VALVE != null) || ($feature.WATER_IN_BARREL != null)) &amp;amp;&amp;amp; ($feature.DATEWORK == null)) 
{
    console("WR")
    // abort if no hydrant was found
    if(hydrant == null) { return };

    //update INSP_STATUS in the hydrant layer to OOS
    return {
        'edit': [{
            'classname' : 'WAT_Hydrant',
            'updates' : [{
                'objectID': hydrant.ObjectID,
                'attributes' : {'INSP_STATUS' : 'WR'}
                        }]
                }]
           };
}

//If it gets this far, then it's just a normal inspection, so set it to Inspected (YES)
console("YES")
console(hydrant.FacilityID)
if(hydrant == null) { return };
return {
    'edit': [{
        'classname' : 'WAT_Hydrant',
        'updates' : [{
            'objectID': hydrant.ObjectID,
            'attributes' : {'INSP_STATUS' : 'YES'}
                    }]
            }]
       };&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 13:09:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-arcade-to-edit-an-attribute-in-another/m-p/1271308#M67135</guid>
      <dc:creator>BrianBulla</dc:creator>
      <dc:date>2023-03-24T13:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using Arcade to edit an attribute in another feature</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-arcade-to-edit-an-attribute-in-another/m-p/1271309#M67136</link>
      <description>&lt;P&gt;I think the verification is run on a default&amp;nbsp; object (new object with all default values). Don't quote me on this...&lt;/P&gt;&lt;P&gt;Your default value for OUT_OF_SERVICE is probably null, so the rule doesn't enter the if block in line 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This might also be why you're no getting the updates you expect. In its current state, the rule will only update the parent feature if&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;OUT_OF_SERVICE is not empty (it accepts any value) and&lt;/LI&gt;&lt;LI&gt;DATEWORK is empty&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;If OUT_OF_SERVICE is empty or DATEWORK is not empty, the rule will not update the parent feature. Is that the expected behavior?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 13:06:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-arcade-to-edit-an-attribute-in-another/m-p/1271309#M67136</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-03-24T13:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using Arcade to edit an attribute in another feature</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-arcade-to-edit-an-attribute-in-another/m-p/1271317#M67138</link>
      <description>&lt;P&gt;Sorry&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;.&amp;nbsp; I actually think it is working.&amp;nbsp; After trying again it's working now.&lt;/P&gt;&lt;P&gt;Thanks for your help!!&amp;nbsp; I was actually talking about this with the Field Maps team while at the Dev Summit a couple weeks ago.&amp;nbsp; It was their idea to try Attribute Rules to automate some logic we are currently using in ArcPad applications in our transition to Field Maps.&amp;nbsp; It looks like this will work.&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 13:14:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-arcade-to-edit-an-attribute-in-another/m-p/1271317#M67138</guid>
      <dc:creator>BrianBulla</dc:creator>
      <dc:date>2023-03-24T13:14:18Z</dc:date>
    </item>
  </channel>
</rss>

