Select to view content in your preferred language

Attribute Rule Not Updating Table With Updates from SQL Server Table

102
1
2 weeks ago
Labels (2)
GreenJosh
Emerging Contributor

Hello,

I have an attribute rule that should update 3 fields in the feature layer 'DayTotals_Dining'. A date Field, a Revenue Field, and a Traffic Field. These should be updated when new entries are inserted into the table 'DinningAll'. The Rule simply sums these values using GroupBy(), and returns an update array. What I've found is that if I manually make inserts to the 'DinningAll' table in ArcPro, the rule functions as intended. The problem is that the updates to the 'DinningAll' table are handled server side via an ETL by our IT department. These updated happen daily, and are reflected in the table when viewed in ArcPro, but for some reason the attribute rule is never triggered.
Anyone ever experience this behavior?

var name = $feature.Name
var yster = Date(DateAdd(DateOnly(), -2, 'days'),Time("11:59 pm"))
var tdy = Date(DateOnly(), Time("12:00 am"))
var data = Count(Filter(FeatureSetbyName($datastore,"PRJ.DinningAll"), "Name = @name AND @tdy >Time AND Time > @yster"))
if(data > 0){
    var rev = GroupBy(Filter(FeatureSetbyName($datastore,"PRJ.DinningAll"),"Name = @name AND @tdy >Time AND Time > @yster"),'Name',[{name: "rev",expression: "Revenue",statistic:"SUM"}])
    var transa = GroupBy(Filter(FeatureSetbyName($datastore,"PRJ.DinningAll"), "Name = @name AND @tdy >Time AND Time > @yster"),'Name',[{name: "transa",expression: "Count",statistic:"SUM"}])
    var target = Filter(FeatureSetbyName($datastore,"PRJ.DayTotals_Dining"), "Name = @name")
    var targetftr = first(target)
    //console(targetftr)
    console(first(rev)["rev"])
    console(first(transa)["transa"])
    console(targetftr.GLOBALID)
    console(DateAdd(Date(), -1, 'days'))
    return{
        "edit":[{"classname":"PRJ.DayTotals_Dining",
        "updates":[{"GlobalID":targetftr.GLOBALID,"attributes":{
        "Revenue":Round(first(rev)["rev"]),"Count_":first(transa)["transa"],"Time":DateAdd(Date(), -1, 'days')}}]}]}}

 

0 Kudos
1 Reply
GreenJosh
Emerging Contributor

To trigger the attribute rule, does there need to be an 'Insert' action? would a scheduled batch calculation work?

0 Kudos