Select to view content in your preferred language

Attribute rule to update a date field when a single field is attributed

1186
2
Jump to solution
03-16-2022 10:58 AM
tbearb
by
Regular Contributor

Using ArcGIS Enterprise 10.9.1 - Field Maps version 21.4.0. I am wondering someone can assist with an issue I came across in an arcade expression that is intended to update a date field when a single field is attributed?

When I apply the following attribute rule to my "Radio_Install_Date" field, I would like for today's date to populate in the "Radio_Install_Date" field when the "Radio_ID" field is attributed. This works as planned. The problem comes when I then update any other field within the feature class as that update causes the date in the "Radio_Install_Date" field to update once more since a value is present in the "Radio_ID" field. The updating stops occurring only when the "Radio_ID" field is empty. 

So, my question is can there be anything added to my expression that would ONLY update the "Radio_Install_Date" field when the "Radio_ID" field is attributed...nothing else?

//Immediate attribute rule on the feature class
//Triggers: Insert, Update
//Field: Radio_Install_Date

var emptyRadioID = $feature.Radio_ID

if (IsEmpty(emptyRadioID)){
    return emptyRadioID}
else{
    return Date()
}

 

0 Kudos
1 Solution

Accepted Solutions
KimGarbade
Frequent Contributor

Try incorporating a compare of the original value to the current value...Can make sure that if the RadioID isn't changed then the Install Date will not change. something like:

if (IsEmpty($feature.RadioID) || $feature.RadioID  == $originalfeature.RadioID){
return $feature.Radio_Install_Date
} else {
return Date()
}

 

View solution in original post

2 Replies
KimGarbade
Frequent Contributor

Try incorporating a compare of the original value to the current value...Can make sure that if the RadioID isn't changed then the Install Date will not change. something like:

if (IsEmpty($feature.RadioID) || $feature.RadioID  == $originalfeature.RadioID){
return $feature.Radio_Install_Date
} else {
return Date()
}

 

tbearb
by
Regular Contributor

Hi @KimGarbade, thank you for the reply. Your recommended edit seems to work well for me, that is exactly what I was looking for. I appreciate your assistance!

0 Kudos