Smart form widget for on-the-fly calculations based on user input

845
2
06-23-2023 05:05 PM
Status: Open
Labels (2)
HollyTorpey_LSA
Occasional Contributor III

I love the functionality of the smart form and the Edit widget, but sometimes I would really love to be able to use that functionality without forcing my users to create and save a feature. I'd love if we could use smart forms for on-the-fly calculations based on user input independent of feature creation/editing.

It would be great if we could specify a feature type (point, line, or polygon) and build a form for it without having it linked to a feature service (or perhaps linking it to an empty feature service to get the schema, domains, data types, etc., but without having to save features... see screenshot below). Then we could take advantage of the form's ability to solicit user input, pull data from map layers via arcade expressions, and output a calculated result for the user.

Use case:

I need to build an app that invites a user to click on a parcel on a map, select a proposed land use, and enter a number of units. Arcade expressions would pull a value from the parcel layer and then calculate an output value based on the land use and the number of units entered by the user.

This value doesn't need to be saved anywhere, and the user should be able to repeatedly adjust the map location, land use, and number of units to see these variables' effects on the output value. I can do all this in a smart form, but then the user is prompted to hit the Create button at the bottom, which makes no sense in this context. If I could customize text at the top of the widget and hide that dang Create button, I'd be in business.

HollyTorpey_LSA_1-1687564669033.png

Combining this with the Draw widget to create temporary input features would be even better.

Thanks!

2 Comments
AlixVezina

@HollyTorpey_LSA, the Edit widget in Experience Builder is the same technology as the Editor from ArcGIS Maps SDK for JavaScript which is built using the FeatureForm.

The FeatureForm could be used to build a widget as you describe. Here is a sample provided by @JoseBanuelos :

Feature Form Arcade Expression (codepen.io)

2023-06-29_14-54-48.gif

In this sample, the value for the field "IsExpired" is updated based on the value set in the "ExpirationDate" field. Anything before today's date is expired, anything after isn't.

In the sample, geometry updates or creation are not provided because the FeaturForm doesn't include drawing capabilities. More code to add drawing capabilities would be needed to support also sketching geometries without actually editing data.

HollyTorpey_LSA

Thanks, @AlixVezina! This is a great head start!