I'm creating a smart form for Field Maps and one of the requirements is to toggle one of the entries to either "Yes" or "No" using a switch. I have the default value set to "No". If the person in the field toggles the switch to "Yes" I want an Arcade expression to update the value for that same record in a date field with the current date of when the switch was toggled to "Yes" for that record.
I tried this but got an error:
var inspection_date = $feature.DATE_INSPECTED; /// date field to be changed with Arcade expression
var inspected = $feature.INSPECTED; /// toggle switch field
IIf(inspected = "Yes", inspection_date = Today(), null); /// condition
The error I get is:
Test execution error: Execution error - undefined. Verify test data.
I think I may need to use a for loop to achieve this but not sure how a response in a smart form would trigger the expression. Is this even possible?