Hello everyone,
I have a rather large form broken into groups of questions. Pieces of the form are filled out over time and as sections are completed they are "closed" for editing. Most of them calculate in the background (hidden).
My issue is that by the time users get to the end of the form, there are many calculations triggering each time any field is edited, even fields that only need to populate once such as an ID or a creation date field.
I have each calculation fields checking for pre-existing values that way its not performing the more extensive portions of arcade. EX:
if (!isEmpty($feature.RecordID)) {return $feature.RecordID}
else {return *script for generating ID*}
I know calculations need to repeatedly search for edits and change dynamically, but is there a more efficient way to skip calculating once initially populated?
Solved! Go to Solution.
The script you mention is the recommended best practice for retaining values during an edit operation. Its pretty efficient because its checking the condition and not running through the calculate again.
Slightly different to the use case you mention above, however we often find folks are affected by both your scenario, and the scenario that you want to maintain values between editing operations i.e. only run on inserting a feature, don't run on an update of an existing feature. In this case you can use:
$editcontext.editType=="X"
X being either INSERT, UPDATE or DELETE (delete isn't really relevant to the calculate profile in Field Maps as calculations will not run on a delete operation). You can then say something like:
if ($editcontext.editType=="INSERT"({
var userInfo = GetUser($layer,'');
return (userInfo["fullname"]);
else {
return $originalFeature.collector_name;
}
The script you mention is the recommended best practice for retaining values during an edit operation. Its pretty efficient because its checking the condition and not running through the calculate again.
Slightly different to the use case you mention above, however we often find folks are affected by both your scenario, and the scenario that you want to maintain values between editing operations i.e. only run on inserting a feature, don't run on an update of an existing feature. In this case you can use:
$editcontext.editType=="X"
X being either INSERT, UPDATE or DELETE (delete isn't really relevant to the calculate profile in Field Maps as calculations will not run on a delete operation). You can then say something like:
if ($editcontext.editType=="INSERT"({
var userInfo = GetUser($layer,'');
return (userInfo["fullname"]);
else {
return $originalFeature.collector_name;
}
Good to know I was on the right path. The editType check sounds very useful as well!
Thank you!