I have a point dataset with a related table for multiple field visits. I want to use Arcade to auto-populate the visit date field (in the related table) for each new record. However it's possible that users may want to go back into a record at a later date and make an edit. This updates the visit date to today's date, which I don't want.
To get around this I put in the following Arcade code. This works great for going in and editing an existing record (i.e. it stops the visit date from being changed), but when I try and create a new record, the visit date populates with today's date but when I try and submit I get an error message "Unable to submit. 1 or more attributes failed".
// If the visit feature is being created, fill in the date with today's date
if ($editcontext.editType == "INSERT") {
var currentdate = Now()
return currentdate
// If it already exists, return the date that was previously filled in
} else {
return $originalFeature.Date_Visit;
}
Can anyone help me figure out the issue please?
Turns out I'm getting that error message even without the Arcade, but I can't delete this question.
It seems really intermittent and sometimes submits, sometimes doesn't, even with just 1 simple text field turned on in Field Maps.