On this page
The validate feature profile automatically runs when any features are added or modified. It is used to determine whether edit is valid or not.
Profile variables
Variable name | Type | Description |
---|---|---|
$map | FeatureSetCollection | The list of layers in the web map. Can be used with the FeatureSetByName or FeatureSetById function to get a particular layer in the map. This can then be queried. |
$userId | Text | The unique user ID of the editor who is logged into the application. |
$userName | Text | The full name of the editor who is logged into the application. |
$userIdentity | Text | Provides a credential instance. This can be used when accessing external layers with the FeatureLayer function. The credentials represent the user’s logged in credentials. |
$session | Dictionary | A dictionary containing key value pairs. The dictionary contains all the session variables that have been configured in the app. When the application first launches, the user will be asked for values for the session variables. They can also (if configured) change session variables in the application. This provides programmatic access to the user’s choices / settings. |
$editingLayer | FeatureSet | The layer to which $feature belongs to. Can be queried to find other records. |
$feature | Feature | The feature that has been edited, added, or worked on. |
$value | Any | The value to test in the script. Certain rules, such as the restrict domain values rule, pass in a value for the current field value. |
$parentFeature | Feature | If there is a geographic contains relationship for the current feature being edited, this variable will contain the parent (or containing feature). |
$routeFeature | Feature | If the feature is a linear referencing feature, this variable will reference source route/line feature. |
$onlyCausedByCracking | Boolean | Boolean value to indicate that this feature has only been changed to add vertices to prevent slithers appearing. |
Return types
Value | Description |
---|---|
true | The feature is valid. |
false | The feature is not valid. |
‘reason’ | Customized reason why the feature is not valid. |
Example
Validate by checking that the feature does not contain too many other features:
/** Validate a geometry by checking it against some conditions.
*
* This script validates that a geometry does not overlap too many wells.
*
* @return - Boolean (true/false)
*/
// get the layer to check against.
var wells = FeatureSetByName($map, "wells");
//find wells which intersect the geometry of the feature.
var overLappingWells = Intersects(wells, Geometry($feature));
//Validate by returning true or false.
if (Count(overLappingWells) > 10) {
return false;
}
return true;