Attribute rule not applying with hosted feature service?

777
4
10-01-2021 07:10 AM
RPGIS
by
Occasional Contributor III

Hi,

I created and attribute rule where the duration field auto-populates with the following values. It runs perfectly fine locally in ArcGIS Pro, but when I publish the hosted layer with this rule it doesn't seem to work. I would greatly appreciate if any could either help or explain the reasoning for this not working.

 

 

var From = Date($feature.OutageStart)
var To = Date($feature.OutageEnd)
var EndTime = Text(To, 'h:mm A')

var LenOfTime_Days = DateDiff(To, From, 'days')
var days = Round(LenOfTime_Days)
var LenOfTime_Hours = DateDiff(To, From, 'hours')
var LenOfTime_Minutes = 60 - Minute(To)

var duration = 'Approximately ' + days + ' day(s) from 9:00 AM - 4:00 PM ending at ' + EndTime + ' on the last day.'

if (LenOfTime_Days >= 1){
return duration
}
else if(LenOfTime_Days < 1 && LenOfTime_Hours != 0 && LenOfTime_Minutes == 60){
duration = LenOfTime_Hours + ' hour(s)'
}
else if(LenOfTime_Days < 1 && LenOfTime_Hours == 0 && LenOfTime_Minutes != 60){
duration = LenOfTime_Minutes + ' minutes'
}
else if(LenOfTime_Days < 1 && LenOfTime_Hours != 0 && LenOfTime_Minutes != 60){
duration = LenOfTime_Hours + ' hour and ' + LenOfTime_Minutes + ' minutes'
}

return duration

 

 

Non-populating field.JPG- Hosted Feature Service in Web Map

Populating attribute rule.JPG - ArcGIS Pro

 

0 Kudos
4 Replies
MicZatorsky_AEC
Occasional Contributor III

Are you publishing to ArcGIS Online or Enterprise?

0 Kudos
RPGIS
by
Occasional Contributor III

I am publishing this to AGO.

0 Kudos
MicZatorsky_AEC
Occasional Contributor III

"Currently, attribute rules are not supported in hosted feature layers in ArcGIS Online."
https://community.esri.com/t5/attribute-rules-documents/attribute-rule-faq/ta-p/910439#toc-hId-42373...

 

0 Kudos
RPGIS
by
Occasional Contributor III

I think they are supported or there is something else that is happening in the background that is occurring. I have a hosted feature service, and the service is currently working where the attribute value changes according to the rule that I set up.

0 Kudos