Select to view content in your preferred language

Attribute Rule to calculate date 10 days from collection date

03-22-2023 01:19 PM
Labels (1)
New Contributor III


Curious at how I would go about this scenario:

A parent feature class (tanks) with child table (maintenance). Say we shock one of the tanks and record that date in table, we want to populate another field in table of when this "shocking" expires eg. 10 days from now. 

I've seen that it is possible in other scenarios like pop-ups and dashboards but haven't found any relavant information on doing this as an attribute rule that can be published in Portal and taken offline for the data collection.

0 Kudos
1 Reply
MVP Frequent Contributor
// Calculation Attribute Rule on the maintenance table
// field: ExpireDate
// triggers: insert

var maintenance_date = $feature.MaintenanceDate
if(maintenance_date == null) {
    // if there is no date value in the field, you have two options:
    // return null (no expire date)
    // use the current date

//    return null  // uncomment this line to return null
    maintenance_date = Today()
var expire_date = DateAdd(maintenance_date, 10, "days")
return expire_date

Have a great day!
0 Kudos