This object allows you to evaluate an ArcadeExpression under a given ArcadeProfile. This Object allows you to set up, execute and query information about an Arcade script. For more general information on Arcade and its usages we refer you to the https://links.esri.com/arcade/.
To construct the ArcadeEvaluator object you need to supply an ArcadeExpression along with an ArcadeProfile. ArcadeExpression is an object that contains the Arcade script plus some additional metadata while ArcadeProfile specifies availability of profile variables and limits what functions are available.
The basic workflow is:
Query information about a script.
Insert the required profile values into a dictionary.
Use the returned ArcadeEvaluationResult.
From an ArcadeEvaluator object you can query information to determine
Which profile variables are accessed by the script.
Which attributes are used by a particular profile variable.
If the script is considered stable.
Not all scripts use all the profiles variables. ArcadeEvaluator.profileVariablesUsed returns an array of the names of the profile variables used in the current script. Possible uses include:
Informing dependency analysis to determine which scripts need to run when a value of a profile variable changes.
Minimizing expensive calculation of unneeded profile variables.
ArcadeEvaluator.getAttributes(String, FeatureTable) lets you dig deeper to determine which attributes are required on a specific profile variable. If you are querying a subset of attributes when querying a feature, use this information to ensure the profile variable will have the attributes it requires.
ArcadeEvaluator.isStable property indicates if the given script will return the same value for an identical set of profile variables. For this to be true a script must avoid using unstable builtin functions such as now() or random().
ArcadeEvaluator.isStable can be combined with the knowledge of the used profile variables to construct caches of results. This lets you avoid running scripts when repeated calls with the same profiles variables will not alter the evaluation result.
Evaluate the script using the supplied profile variables. Each entry of the profileVariables dictionary is placed into the interpreter as a value accessible throughout the script. The name and type of these should comply with the profile the Arcade evaluator has been constructed with. Values are not persisted across evaluations, meaning all required profile variables must be supplied with each evaluation.
An array of attributes used in the script for a given profile variable. To fully support the wildcard expansion in the expects statement, calculation of used attributes on a profile variable requires an object that can supply a full set of attribute names.