0

I have a point layer and a standalone table within a relationship class that both have date fields. I have an Arcade script that is supposed to update the date field within the point layer using the date from the standalone table. I have created an attribute rule within the standalone table with this expression input:

// Get the related water meter feature from the point layer
var water_meter = First(FeatureSetByRelationshipName($feature, "DBO.SampleTest_SampleAssessment"))

// If there's no related water meter feature, return "<Null>"
if (water_meter == null) {
  return "<Null>";
}

// Get the attributes from the water meter
var old_attributes = {
  "Date": water_meter.Date
};

// Map the attribute names from the work table to the feature class
var update_attribute_map = [
  ["TestDate", "Date"]
];

// Initialize an empty dictionary to store updated attributes
var updated_attributes = Dictionary();

// Loop through the update_attribute_map
for (var i in update_attribute_map) {
  var work_att = update_attribute_map[i][0]; // Attribute name from the work table
  var asset_att = update_attribute_map[i][1]; // Attribute name in the feature class
  var new_att = $feature.TestDate; // New attribute value from the standalone table
  var old_att = water_meter[asset_att]; // Old attribute value from the water meter feature
  
  // If the new attribute value is not empty, add it to the updated_attributes dictionary
  if (!IsEmpty(new_att)) {
    updated_attributes[asset_att] = new_att;
  }
}

// Create an edit request to update the water meter feature with the new attributes
var edit = [
  {
    "className": "DBO.SampleTest", // Replace with the name of your point layer class
    "updates": [
      {
        "globalID": water_meter.globalId,
        "attributes": updated_attributes
      }
    ]
  }
];

// Return the edit request
return {
  "edit": edit
};

It's trigger is "Insert". After applying this attribute rule, it prompts an error stating Return type is not compatible with the field type. Both field types are "Date". Is there something missing from my script or is this process just not compatible with Date field types?

0

Browse other questions tagged or ask your own question.