Hello!
Not sure if it's me or something else on this one, but I need your help! For our workflow, I want to populate a date field with the current date and time IF (1) it should be populated based on other choices and (2) it's not already populated.
What I've noticed seems to be happening is that even if the date has a value, when the arcade is evaluated in Experience Builder, the value is coming back empty. This might be a bug...
Here's the arcade for the Check Out Time in the following screenshots.
var checkOutTime = $feature.CheckOut;
var attendance = $feature.Attendance;
var checkOut = $feature.CheckOutChoice;
if(attendance=='Present' && checkOut == 'Yes'){
if (2 == 1){
checkOutTime = Now();
}
}
return checkOutTime;
In this example, both the check in and check out time are populated. Here's how the edit form looks in the web map.
And here's the same record in the edit widget in Experience Builder. Since the check out date is coming through as null -- i'm thinking that the value isn't getting sent to the arcade expression maybe?
The values are being shown as expected in the pop up displays ..
Thanks for any ideas you might have!
Solved! Go to Solution.
Hi @jessneuner
The edit widget seems like an "attribute only" mode.
I guess the "attribute only" mode does not support arcade expression currently.
I tested a "map" mode edit widget, and found the arcade fields worked.
Maybe you can try the map mode.
Hi @jessneuner
The edit widget seems like an "attribute only" mode.
I guess the "attribute only" mode does not support arcade expression currently.
I tested a "map" mode edit widget, and found the arcade fields worked.
Maybe you can try the map mode.
aaah... dang. This is a stand alone table. hmm...
I have a different field with a calculation that is working great -- just this date field that's causing me trouble.
Try select the "Use webmap settings" in "Configure fields".
The "Customize" has some problem I just remember.
Thanks @Allen_Zhang Does seem like an Attribute_only vs map thing. Did a similar test with a feature layer instead of stand alone table this morning and saw the same behavior (just a simple pass through of the value with the arcade calculation) and they didn't pass through in attribute only mode, but did in the map side.
bummer! i have a Survery123 version of the logic that works great - the UX isn't quite as nice as the edit widget but will get the job done!
appreciate your help!
var checkOutTime = $feature.CheckOut;
var attendance = $feature.Attendance;
var checkOut = $feature.CheckOutChoice;
if(attendance=='Present' && checkOut == 'Yes'){
if (2 == 1){
checkOutTime = Now();
}
}
return checkOutTime;
if 2 = 1 means it will always return false? what's the point of this if statement?
I would recommend:
e.g.
var mode = $editcontext.editType;
if (mode == "INSERT") {
return now()
} else {
return $originalFeature.checkintime
}
and
var CheckedOut = $feature.CheckedOut; // Checked out 'Yes'?
var OriginalCheckOutTime = $originalFeature.CheckOutTime; // current checkout time on form load
// Check if CheckedOut is 'Yes' and CheckOut time is currently empty
if (CheckedOut == 'Yes' && IsEmpty(OriginalCheckOutTime)) {
return Now();
} else {
return OriginalCheckOutTime// Use $originalFeature to get the original field value which would be null or the first checkout time calculated
}
Some of syntax might not quite be right sorry just writing this off memory on the forum 😄
thanks @ChristopherCounsell !
I appreciate you taking a look -- the 2=1 came about because I was confused why it was always updating the date to Now even when it was already populated, so wanted it to skip that part and that's when I realized -- is it not even getting the date??
Thank you for the tip on edit mode also! I wound up going down that rabbit hole last night as well -- and all the visibility stuff ... I realized that even if values are hidden those calculations are getting executed which i hadn't expected ... learning a lot!