Select to view content in your preferred language

Arcade expression update field

483
1
02-17-2023 02:31 PM
pketeldijk
New Contributor

I have a feature layer with a datefield (inspection_date) and a domain field (maintenance). 

 
The datefield gets populated by related records. When a related record is added the datefield (inspection_date) in the feature layer is updated using an attribute rule. 
 
I would like the maintenance field (which is a domain) to automatically change to ‘inspection needed’ after 20 days of the datefield, by using an attribute rule. I have the following expression, but keep getting an error. Can someone help me out. 
 
var numDays = 20;
var days = DateDiff(‘days’,Date(‘today’),$feature.inspection_date);
If(days > numDays, ‘inspection needed’, $feature.maintenance)
 

 

Tags (2)
0 Kudos
1 Reply
JohannesLindner
MVP Frequent Contributor
  • You have the wrong order of arguments for DateDiff
  • Date('today') isn't a thing, Today is
  • You want to use IIf
  • You're not using the correct quote marks, but some mixture of apostrophes and accents, but that might be because you posted your code as text
var numDays = 20;
var days = DateDiff(Today(), $feature.inspection_date, 'days');
return IIf(days > numDays, 'inspection needed', $feature.maintenance)

 


Have a great day!
Johannes
0 Kudos