Select to view content in your preferred language

Undefined Keyword Error

70
3
Jump to solution
Tuesday
BillMoody
New Contributor III

Trying to create a fairly simple attribute rule on a line feature that will take various values from a table and divide them by another field containing the calculated length of the segment in miles and then return the result to the appropriate fields.  This is set to trigger on insert and update

// Retrieve values and handle nulls
var lengthMiles = $feature.LengthMiles;
var totalCrashes = DefaultValue($feature.TotalCrashes, 0);
var fatalCrashes = DefaultValue($feature.FatalCrashes, 0);
var injuryCrashes = DefaultValue($feature.InjuryCrashes, 0);
var propertyCrashes = DefaultValue($feature.PropertyCrashes, 0);
var pedestrianGenerator = DefaultValue($feature.PedestrianGenerator, 0);

// Initialize the result dictionary
var result = {
    'CrashesPerMile': 0,
    'FatalCrashes_PerMile': 0,
    'InjuryCrashes_PerMile': 0,
    'PropertyCrashes_PerMile': 0,
    'PedGen_PerMile': 0
};

// Calculate per mile values if lengthMiles is greater than 0
if (lengthMiles > 0) {
    result['CrashesPerMile'] = totalCrashes / lengthMiles;
    result['FatalCrashes_PerMile'] = fatalCrashes / lengthMiles;
    result['InjuryCrashes_PerMile'] = injuryCrashes / lengthMiles;
    result['PropertyCrashes_PerMile'] = propertyCrashes / lengthMiles;
    result['PedGen_PerMile'] = pedestrianGenerator / lengthMiles;
}

// Return the result object
return result;

 

The check tells me that the rule is valid  but when I go to create a new line on the map, I get this error:
Triggering event: Insert,
Class name: PublicWorksInternal.DBO.TrafficCalmingProjects,
GlobalID: {345DBCDD-2B43-4EF1-9BF8-94F0A82ACFBA}]Undefined keyword is used in the dictionary return script. [CrashesPerMile] 

 

Thanks for any help!

0 Kudos
1 Solution

Accepted Solutions
Jake_S
by Esri Contributor
Esri Contributor

@BillMoody you'll need to use proper distortionary keywords to insert the values into the proper attributes. The documentation is here, Attribute rule dictionary keywords.

~Jake

 

View solution in original post

3 Replies
Jake_S
by Esri Contributor
Esri Contributor

@BillMoody you'll need to use proper distortionary keywords to insert the values into the proper attributes. The documentation is here, Attribute rule dictionary keywords.

~Jake

 

BillMoody
New Contributor III

Fixed!  Thank you @Jake_S!

0 Kudos
Jake_S
by Esri Contributor
Esri Contributor

Most welcome!! @BillMoody 

0 Kudos