Immediate Calculation Rule "stealing" value

121
2
Jump to solution
09-16-2021 12:23 PM
BHeist
by
New Contributor III

@HusseinNasser2 

 

I have a SDE database and I have a related table within the database. The table is housing records submitted from Survey123 for liquid level readings. I would like to visual some of these submitted readings, but I don't want to create a join to do so. As an alternative I have implemented an Attribute Rule for the field containing the values I would like to visual by. In another layer within my database I have added a new field in order to write the value from the table into. I have done this successfully. So when a new record is inserted in the related table, my Attribute Rule successfully executes and writes my desired value into the other layer within my database. The only issue is that the value doesn't end up in the related table. It's like the Attribute Rule is stealing it before it is finally inserted into the table. 

Is this expected behavior? A way to work around this?

Any insight you could provide would be much appreciated! 

Please see my code below:

 

//Field: toc_to_liquid_1
//Trigger: insert
//Execution: Exclude from application evaluation


//The example below is a calculation rule on a text field of a liquid level survey table. 
//When a new record is inserted within the survey table the value from the text field is written into a corresponding field in the master layer 

// Master layer accessed as a Feature Set
var masterLayer = FeatureSetByName($datastore,'L0RMCDemo_GIS_SDE_RMC_Demo_Master_Layer', ['globalid', 'Point_ID', 'current_liquid_level'], false);
//Extraction well point_id
var pointID = $feature['well_id']; 


// Filter statement (SQL) - access variable with @
var filterStatement = 'Point_ID = @pointID'; 

// Filter the master layer by the filter statement - grabs the value that matches from Master to LL Table
var masterFilter = Filter(masterLayer, filterStatement);

var currentTOC = [];

for (var record in masterFilter) {
    currentTOC = [{
        'globalid': record.GlobalID,
        'attributes':  {
            'current_liquid_level': $feature.toc_to_liquid_ft_1
        }
    }];
    return {
        'edit': [{
            'className': 'RMCDemo_GIS.SDE.RMC_Demo_Master_Layer',
            'updates': currentTOC
        }]
    }
}

 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
Regular Contributor

The last part of your rule is a little wonky:

  • Instead of appending to currentTOC in the for loop, you overwrite it constantly.
  • You return in the for loop, so the first entry of masterFilter is the only one being changed.
  • You do return the edit, but you don't return the result for the field, which is probably why the value is "stolen".
var currentTOC = [];

for (var record in masterFilter) {
    var update = [{
        'globalid': record.GlobalID,
        'attributes':  {
            'current_liquid_level': $feature.toc_to_liquid_ft_1
        }
    }];
    Push(currentTOC, update)
    // for older Arcade versions (pre ArcGIS Pro 2.8):
    // currentTOC[Count(currentTOC)] = update
}
return {
    'result': $feature.toc_to_liquid_ft_1,
    'edit': [{
        'className': 'RMCDemo_GIS.SDE.RMC_Demo_Master_Layer',
        'updates': currentTOC
    }]
}

Have a great day!
Johannes

View solution in original post

2 Replies
JohannesLindner
Regular Contributor

The last part of your rule is a little wonky:

  • Instead of appending to currentTOC in the for loop, you overwrite it constantly.
  • You return in the for loop, so the first entry of masterFilter is the only one being changed.
  • You do return the edit, but you don't return the result for the field, which is probably why the value is "stolen".
var currentTOC = [];

for (var record in masterFilter) {
    var update = [{
        'globalid': record.GlobalID,
        'attributes':  {
            'current_liquid_level': $feature.toc_to_liquid_ft_1
        }
    }];
    Push(currentTOC, update)
    // for older Arcade versions (pre ArcGIS Pro 2.8):
    // currentTOC[Count(currentTOC)] = update
}
return {
    'result': $feature.toc_to_liquid_ft_1,
    'edit': [{
        'className': 'RMCDemo_GIS.SDE.RMC_Demo_Master_Layer',
        'updates': currentTOC
    }]
}

Have a great day!
Johannes

View solution in original post

BHeist
by
New Contributor III

Duh! Was missing the 'result' portion. No wonder nothing was being returned. Thanks! 

0 Kudos