<?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: Need Help with Arcade Script for Insert Trigger in Survey123 and ArcGIS Enterprise in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1350023#M1195</link>
    <description>&lt;P&gt;Now it validates! thanks for your help on this.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Nov 2023 22:44:41 GMT</pubDate>
    <dc:creator>JuneAcosta</dc:creator>
    <dc:date>2023-11-15T22:44:41Z</dc:date>
    <item>
      <title>Need Help with Arcade Script for Insert Trigger in Survey123 and ArcGIS Enterprise</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1347692#M1178</link>
      <description>&lt;P&gt;Hello ArcGIS Community,&lt;/P&gt;&lt;P&gt;I am currently working on an Arcade script for an Insert trigger, and I'm facing some challenges. Your expertise and guidance would be immensely valuable to help me troubleshoot and refine my script.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I look forward to your responses and appreciate your time and support.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Objective:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I am developing a Survey123 app that points to an enterprise layer named `BCCpointclass` within ArcGIS Enterprise, not a hosted layer in AGOL. Each time a new point is created in the survey, I want to use an attribute rule on BCCpointclass to create a duplicate of a newly created point and all its attributes in another enterprise point feature class named `BCC_JuneSnapShot`.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Issue:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;From the script below in the expression builder I get the error. "Invalid expression. Error on line 20. Identifier expected.&lt;/P&gt;&lt;P&gt;I put a script together from the example in&amp;nbsp;this 2019.&lt;/P&gt;&lt;P&gt;This is my script:&lt;/P&gt;&lt;P&gt;// Get the global ID of the point feature being inserted&lt;BR /&gt;var globalId = $feature.globalid;&lt;/P&gt;&lt;P&gt;// Find the corresponding feature in the BCC_JuneSnapShot feature class&lt;BR /&gt;var snapshotFeatureClass = FeatureSetByName($datastore, "BCC_JuneSnapShot");&lt;BR /&gt;var filteredFeatures = FeatureSet(&lt;BR /&gt;Filter(snapshotFeatureClass, "pointGuid = @globalId")&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;// If no matching feature is found, create a new feature&lt;BR /&gt;var newFeature;&lt;/P&gt;&lt;P&gt;if (Count(filteredFeatures) == 0) {&lt;BR /&gt;// Create a new feature in BCC_JuneSnapShot&lt;BR /&gt;newFeature = snapshotFeatureClass.createFeature();&lt;/P&gt;&lt;P&gt;// Set the geometry and attributes from BCCpointclass to BCC_JuneSnapShot&lt;BR /&gt;Set(newFeature, 'geometry', $feature.geometry);&lt;BR /&gt;for (var field in $feature) {&lt;BR /&gt;if (field !== 'geometry') {&lt;BR /&gt;newFeature[field] = $feature[field];&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Save the new feature in BCC_JuneSnapShot&lt;BR /&gt;snapshotFeatureClass.addFeature(newFeature);&lt;BR /&gt;} else {&lt;BR /&gt;// If a matching feature exists, exit without making changes&lt;BR /&gt;return $feature.field;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Return the value of the field 'Field' without change&lt;BR /&gt;return $feature.field;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 14:21:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1347692#M1178</guid>
      <dc:creator>JuneAcosta</dc:creator>
      <dc:date>2023-11-09T14:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Arcade Script for Insert Trigger in Survey123 and ArcGIS Enterprise</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1347889#M1188</link>
      <description>&lt;P&gt;When posting code, please use the code snippet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This should get you closer:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Get the global ID of the point feature being inserted
var globalId = $feature.globalid;

// Find the corresponding feature in the BCC_JuneSnapShot feature class
var snapshotFeatureClass = FeatureSetByName($datastore, "BCC_JuneSnapShot");
var filteredFeatures = Filter(snapshotFeatureClass, "pointGuid = @globalId");

if (Count(filteredFeatures) != 0) {
    return $feature.field;
}

var copy_feature = dictionary($feature);
copy_feature['geometry'] = $feature.geometry
return {
      "result": $feature.field,
       "edit": [  
           {  
               "className" : "BCC_JuneSnapShot",
               "adds" : [copy_feature ]
            }
     ]
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 09 Nov 2023 19:24:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1347889#M1188</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2023-11-09T19:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Arcade Script for Insert Trigger in Survey123 and ArcGIS Enterprise</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1349343#M1189</link>
      <description>&lt;P&gt;Thanks for responding. I get the error Invalid expression. Error on Line 12 . Invalid JSON. I tried to troubleshoot and change the script a bit but still get the same error.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2023 19:57:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1349343#M1189</guid>
      <dc:creator>JuneAcosta</dc:creator>
      <dc:date>2023-11-14T19:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Arcade Script for Insert Trigger in Survey123 and ArcGIS Enterprise</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1349363#M1190</link>
      <description>&lt;P&gt;Can you share a fgdb with your source and target classes?&amp;nbsp; Would be easier to troubleshoot.&lt;/P&gt;&lt;P&gt;Here is a good sample to follow too -&amp;nbsp;&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"&gt;https://www.esri.com/arcgis-blog/products/arcgis-pro/data-management/advanced-gdb-attribute-rules-editing-external-features-with-attribute-rules/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2023 20:42:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1349363#M1190</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2023-11-14T20:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Arcade Script for Insert Trigger in Survey123 and ArcGIS Enterprise</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1349423#M1191</link>
      <description>&lt;LI-CODE lang="javascript"&gt;// Get the global ID of the point feature being inserted
var globalId = $feature.globalid;

// Find the corresponding feature in the BCC_JuneSnapShot feature class
var snapshotFeatureClass = FeatureSetByName($datastore, gisdata.sdeowner.JuneBackup");
var filteredFeatures = Filter(snapshotFeatureClass, "BCCGuid = @globalId");

if (Count(filteredFeatures) != 0) {
    return $feature.field;
}

var copy_feature = dictionary($feature);
copy_feature['geometry'] = $feature.geometry
return {
      "result": $feature.field,
       "edit": [  
           {  
               "className" : "JuneBackup",
               "adds" : [copy_feature ]
            }
     ]
}&lt;/LI-CODE&gt;&lt;P&gt;I'm working against an enterprise geodatabase- above shows how I reference the data in the script. I have also attached the schema for my layers.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2023 22:46:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1349423#M1191</guid>
      <dc:creator>JuneAcosta</dc:creator>
      <dc:date>2023-11-14T22:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Arcade Script for Insert Trigger in Survey123 and ArcGIS Enterprise</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1349489#M1192</link>
      <description>&lt;P&gt;This works in the gdb you sent.&amp;nbsp; I added a function that will copy the attributes from the input feature, just remove the fields you want to persist.&amp;nbsp; and then set line 25 to use the filtered_atts variable&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;// Get the global ID of the point feature being inserted
var globalId = $feature.globalid;

// Find the corresponding feature in the BCC_JuneSnapShot feature class
var snapshotFeatureClass = FeatureSetByName($datastore, "JuneBackup");
var filteredFeatures = Filter(snapshotFeatureClass, "BCCGuid = @globalId");

if (Count(filteredFeatures) != 0) {
    return;
}

function pop_keys(dict, keys) {
    var new_dict = {};
    for (var k in dict) {
        if (IndexOf(keys, Upper(k)) != -1) {
            continue;
        }
        new_dict[k] = dict[k];
    }
    return new_dict;
}
var copy_feature = dictionary($feature);
var fields_to_not_copy = ['OBJECTID', 'Shape', 'CreationDate', 'Creator', 'EditDate', 'Editor', 'BCCCHOICES', 'DOB', 'HOMEADDRESS', 'EMAIL', 'EMPLOYER', 'EMPLOYERADDRESS', 'EXPLANATIONS', 'EDUCATIONBACKGROUND', 'RELEVANTEXPERIENCE', 'ADDITIONALINFOCOMMENTS', 'EMPLOYERADDRESSCITY', 'EMPLOYERADDRESSZIP', 'SUBMITDATE', 'ISCARLSBADRESIDENT', 'ISCARLSBADREGISTEREDVOTER', 'ISWILLINGDISCLOSEFINANCIAL', 'ISWILLINGETHICSTRAINING', 'FIRSTNAME', 'LASTNAME', 'HOMEADDRESSCITY', 'HOMEADDRESSZIP', 'COUNCILDISTRICT', 'WORKMOBILEPHONE', 'ACKCITYEMPLOYEE', 'ACKCITYCONTRACTOR', 'ACKCITIZENACADEMYGRAD', 'ACKRESPONSIBILITIES', 'ACKINTERVIEWWILLING', 'APPOINTEDBCC', 'STATUS', 'APPOINTEDDATE', 'TERMEXPIRATIONDATE', 'STAFFINITIALS', 'EMPLOYMENTSTATUS', 'SUBMITTERACKNOWLEDGETYPE', 'SUBMITTERACKNOWLEDGECHECK', 'INTEREST', 'APEXYEAR', 'ACKCITYEMPLOYEEPAST', 'PRIMARYPHONE', 'SECONDARYPHONE', 'WORKPHONE', 'COMMUNITYINVOLVEMENT', 'SERVICEONBCC', 'SERVICEONBCC2', 'SERVICEONBCC3', 'SERVICEONBCC4', 'SERVICEONBCC5', 'APPOINTEDPOSITION', 'APPOINTEDCATEGORY', 'NOMINATINGCOUNCILMEMBER', 'ApplicantID', 'created_user', 'created_date', 'last_edited_user', 'last_edited_date', 'GlobalID']
var filtered_atts = pop_keys(copy_feature['attributes'],fields_to_not_copy)
copy_feature['attributes'] = {}
copy_feature['attributes']['BCCGuid'] = $feature.GlobalID;
copy_feature['geometry'] = Geometry($feature)
return {
       "edit": [  
           {  
               "className" : "JuneBackup",
               "adds" : [copy_feature]
            }
     ]
}&lt;/LI-CODE&gt;&lt;P&gt;cop&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2023 00:30:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1349489#M1192</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2023-11-15T00:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Arcade Script for Insert Trigger in Survey123 and ArcGIS Enterprise</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1349501#M1193</link>
      <description>&lt;P&gt;I'm still encountering the same issue with the script. The error message "invalid JSON on line 22" keeps appearing, and it seems to be linked to the line var copy_feature = dictionary($feature), just like in the previous scripts.&lt;/P&gt;&lt;P&gt;The problem persists when I test the script with both egdb and fgdb. I'm using ArcGIS Pro version 3.1.2. Could this issue be related to my version of ArcGIS Pro or Python? Which version of ArcGIS Pro are you using?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2023 02:37:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1349501#M1193</guid>
      <dc:creator>JuneAcosta</dc:creator>
      <dc:date>2023-11-15T02:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Arcade Script for Insert Trigger in Survey123 and ArcGIS Enterprise</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1349506#M1194</link>
      <description>&lt;P&gt;I am on 3.2.&amp;nbsp; Looks like Dictionary on Feature was not added till 3.2.&amp;nbsp; Change the line to&amp;nbsp;&lt;/P&gt;&lt;P&gt;var copy_feature = dictionary(Text($feature));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H4&gt;Dictionary(inputFeature) -&amp;gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/arcade/guide/types/#dictionary" target="_blank" rel="noopener"&gt;Dictionary&lt;/A&gt;&lt;/H4&gt;&lt;P&gt;&lt;STRONG&gt;&lt;A href="https://developers.arcgis.com/arcade/guide/version-matrix/" target="_blank" rel="noopener"&gt;Since version 1.23&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2023 02:45:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1349506#M1194</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2023-11-15T02:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Arcade Script for Insert Trigger in Survey123 and ArcGIS Enterprise</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1350023#M1195</link>
      <description>&lt;P&gt;Now it validates! thanks for your help on this.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2023 22:44:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1350023#M1195</guid>
      <dc:creator>JuneAcosta</dc:creator>
      <dc:date>2023-11-15T22:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Arcade Script for Insert Trigger in Survey123 and ArcGIS Enterprise</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1369317#M1240</link>
      <description>&lt;P&gt;I am trying to do something very similar, but using Attribute Rules. I tested this out, but am getting a few errors (not sure if everything translates between where you were using this and where I want to use it in ArcPro)? Thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 00:18:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/need-help-with-arcade-script-for-insert-trigger-in/m-p/1369317#M1240</guid>
      <dc:creator>VanessaSimps</dc:creator>
      <dc:date>2024-01-12T00:18:02Z</dc:date>
    </item>
  </channel>
</rss>

