xiao8579 / QuickCapture-Testing

Repo for feedback and issues during QuickCapture testing events.
0 stars 0 forks source link

[Advanced Exercise] Arcade expression #79

Open xiao8579 opened 1 year ago

xiao8579 commented 1 year ago

Description

Calculate field values using an Arcade expression​.

Test

How to configure?

Coming soon: use QuickCapture designer to write and test your Arcade expressions for a selected data field.

For testing purposes:

  1. Compose and test your arcade expressions with Calculate function in Map Viewer Classic image

  2. When done with testing, copy and paste the script to the target Text field with in your project.

    • "${arcadeExpression: _your scripts goes here_}"
    • Note: the script needs to be presented as a single line. Use Escape characters (e.g. \n - new line) image
  3. Save the project.

How does it work on the mobile app?

  1. Download and open your project.
  2. Tap the button to capture data.
  3. The mobile app will calculate value for the selected data field while you capture data.
  4. Verify the submitted data and calculated field value on the feature layer.
IsmaelInRedlands commented 1 year ago

@xiao8579 Arcade expressions are evaluated when the data is about to be sent to ArcGIS. This guarantees that the device is connected and ensures any expression that uses a web service will work fine. Expressions are not evaluated at the time when data is collected. May want to clarify in the instructions.

JohnHasthorpe commented 1 year ago

Test project: Accuracy conversion image

This uses an arcade expression to calculate the horizontal accuracy in feet from the value meters.

image image

Results: https://quickcapture.maps.arcgis.com/home/item.html?id=8dcb2b6f7a5f4a6886504beb6332c194#data

jlindemann commented 1 year ago

Testing just very basic calculations like John's above works on iPhone 11.

jenlangevin commented 1 year ago

Just an observation, the arcade expression is limited by the length of the field. For example, I have a field length of 4 to accommodate only a year. I wanted to test an arcade expression to write the year for me so I do not have to go back and enter them manually but I will have the change the field length to do so.

lbotha commented 1 year ago

Calculation like in example works, pull pt in polygon, having issues with that, might be syntax error?

marikavertzonis commented 1 year ago

i started by crafting my expression in the Map Viewer: image

and then removed the carriage returns and placed this in the value field for lady bug notes:

"value": "${arcadeExpression: var region = FeatureSetByName($map,'Catchments - Waterways and Drains Subcatchments', ['SUB_CATCHMENT_NAME'])\n var region = First(Intersects($feature, region))\n if (!IsEmpty(region)) {return region['SUB_CATCHMENT_NAME']} else {return null}}"

i did need to manually change the "" that were generated in Map Viewer to be '' in QuickCapture

this is the result in Map Viewer: (the notes field is populated with the name of the sub catchment polygon within which the lady bug was located. expression only placed on lady bugs.

image

data captured on android, pixel 6