AnsweredAssumed Answered

Arcade For Loop & Attribute Updates on other Features

Question asked by TLongSUGF on Aug 5, 2020
Latest reply on Aug 6, 2020 by xander_bakker

I am having trouble with for loops.  This example prints out the second item in the array.


var array = ["RC-22p", "RC-22e"];;

for(var c in array) {
    var invoice = array[c]
    return invoice

The result is RC-22e.


I am trying to loop through an array, look up the corresponding globalid and update that related record.  When I run my code the first item in the array is completed, but it stops after the first one, it doesn't loop...  How can I get my for loop to loop when my return is updating another feature class?


var array = ["RC-22H", "RC-22I"];
var pipe = "";
var invoice = "";
var i = "";
var c = "";
for(var c in array)
//lookup globalid based on item in array
    var pipe = FeatureSetByName($datastore,"SUDOECMS.DBO.doe_EAP_pipelineabandon");
    var invoice = filter(pipe, "invoice = '" + array[c] + "'");
    var i = first(invoice);
//if feature value is q_1, update the other record       
    if ($feature.q_x == 'q_1'){    
            return {
               "result": $feature.q_x,
                   'edit': [{
                       'className': 'SUDOECMS.DBO.doe_EAP_pipelineabandon',
                   'updates': [{
                       'globalID': i.GlobalID,
                       'attributes': {
                           'q_1': $feature.status,
                           'q_1comments' :  $feature.q_xcomments,
                           'q_1rank' :  $feature.q_xrank
//stops here but I want to repeat, it only updates the other record based on RC-22H, it does not update RC-22I.               

Xander Bakker