Hi everyone.
I'm trying to create an attribute rule that changes a domain value when a specific date is passed.
So the main problem I'm trying to solve is this:
When a feature is created, the feature gets domain code 105. When the feature is up for review in a process, the administrator changes the domain code from 105 to a value between 100-104 and sets a end date in another field. When the end date is passed I want the domain code to change back to 105.
Here is the Arcade-code I've been working on. It validates just fine, but when I execute the rule the domain value does not change.
var skedenr = $feature.Skede
var utstallningsdatum = $feature.Utstallningsdatum
var dagensdatum = Today()
var skede = IIF(skedenr != 105, '1', '3')
var datum = DateDiff(utstallningsdatum, dagensdatum)
var datums = IIF(datum <= 0, '1', '3')
var sant = IIF(skede + datums == 2, 105, skedenr)
return sant
Super grateful for help!
Solved! Go to Solution.
It sounds as if you want the field to update itself when the specified date is passed. That is not possible. An Attribute Rule only triggers when you actively do something to a feature (insert/update/delete), they are not checked continually.
What you can do is create a Batch Attribute Rule. These are rules that don't trigger on insert/update/delete, but are evaluated when the user wants.
var skedenr = $feature.IntegerField
var utstallningsdatum = $feature.DateField
if(skedenr == null || skedenr == 105) {
return 105
}
if(utstallningsdatum == null) {
return skedenr
}
var datum = DateDiff(utstallningsdatum, Today())
return IIF(datum <= 0, 105, skedenr)
My test features before and after evaluating the rule (on 2022-03-24)
Before | After |
Notes:
var datum = DateDiff(utstallningsdatum, Today(), "hours")
return IIF(datum <= 1, 105, skedenr)
It sounds as if you want the field to update itself when the specified date is passed. That is not possible. An Attribute Rule only triggers when you actively do something to a feature (insert/update/delete), they are not checked continually.
What you can do is create a Batch Attribute Rule. These are rules that don't trigger on insert/update/delete, but are evaluated when the user wants.
var skedenr = $feature.IntegerField
var utstallningsdatum = $feature.DateField
if(skedenr == null || skedenr == 105) {
return 105
}
if(utstallningsdatum == null) {
return skedenr
}
var datum = DateDiff(utstallningsdatum, Today())
return IIF(datum <= 0, 105, skedenr)
My test features before and after evaluating the rule (on 2022-03-24)
Before | After |
Notes:
var datum = DateDiff(utstallningsdatum, Today(), "hours")
return IIF(datum <= 1, 105, skedenr)
It works just fine.
I am so grateful for your help!